Hello
Im am tryint to send a string from python to matlab. But how can i send a string including ".
Example:
Firs what matlab need.
matlab.Execstme("fprintf('%6.3f\n',test)")
And now i will send an variable so i write this
def setVarSim(self, varName, varValue):
"executes Matlab command, for setting value, return nothing"
mlab_code = varName+"="+varValue
return self.matlab.Execute(mlab_code)
This will not work becuse matlab need "statement" and if write "" it looks like an string for python.
Any idea? Or am i not clear enougth?
8 1674
Not working
self.matlab.Execute(\" mlab_code \")
Not working
self.matlab.Execute(\" mlab_code \")
how about this
self.matlab.Execute("''%s'" % mlab_code)
noep
>>> matlab.setVarSim(test,22)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "L:\workspace\TestMlab\src\default\test_script_wea therstation.py", line 25, in setVarSim
mlab_code = varName+"="+varValue
TypeError: coercing to Unicode: need string or buffer, int found
hmmmmm?
noep
>>> matlab.setVarSim(test,22)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "L:\workspace\TestMlab\src\default\test_script_wea therstation.py", line 25, in setVarSim
mlab_code = varName+"="+varValue
TypeError: coercing to Unicode: need string or buffer, int found
hmmmmm?
the error says it all, if my guess is correct, your varValue is a number so doing this:
str(varValue) might solve the problem
Thanks.
now im just have one problem. how can i define my function so mi argument is charachter.
example:
in java or c you can define what you argument is like
test_function(char test, int var)
if you want, you can set your argument to a default null string.eg
because Python is a dynamically typed language, there's no need to declare your variables. you just "change" the type around when you need it. -
def func(mi):
-
if str(mi): #make m to be string.
-
.....
-
do_somethingelse( int(m) ) #make m to be integer
-
try:
-
int(m)
-
except: print "cannot make to integer"
-
....
-
Thanks.
now im just have one problem. how can i define my function so mi argument is charachter.
example:
in java or c you can define what you argument is like
test_function(char test, int var)
I just found PyMat.
I hope MatLab users find this useful.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Robin Tucker |
last post by:
Hi,
I would like to select records from a table where the following criteria
hold:
SELECT * from Mytable where
field x "contains" string @X
or
|
by: Eric Theil |
last post by:
I'm at my wit's end with this one. Within an xsl:if test, I'm not able to
get 2 variables to properly evaluate if one of them is wrapped within a
string function.
<!-- This works -->
<xsl:if...
|
by: Indrid Colt |
last post by:
Thank's for your help !
Indrid
|
by: Jay S |
last post by:
Hi,
Can't figure out the following:
<concept>
I want to match a specified string followed by any string that is *not* a
different specified string.
</concept>
<specific example>
|
by: Fei Liu |
last post by:
In Accellerated C++, the author recommends that in a header file one should
not declare
using std::string, using std::vector etc instead one should directly specify
the namespace specifier in...
|
by: lovecreatesbea... |
last post by:
Is it correct and safe to compare a string object with "", a pair of
quotation marks quoted empty string?If the string object: s = ""; does
s contain a single '\'? Is it better to use...
|
by: Lothar Behrens |
last post by:
Hi,
I have selected strtok to be used in my string replacement function.
But I lost the last token, if there is one.
This string would be replaced
select "name", "vorname", "userid",...
|
by: dhtmlkitchen |
last post by:
Why does "foo" instanceof String return false?
It just seems counterintuitive to me.
I mean, sure, I can always check the constructor:
var fooVar = "foo";
var isString =...
|
by: mato81 |
last post by:
Hi all!
I am a newbie to WSDL. I have a questions which has been driving me crazy...
If I would have a WSDL with a types element somewhat like below, what is the point of the third last row...
|
by: kevineller794 |
last post by:
I want to make a split string function, but it's getting complicated.
What I want to do is make a function with a String, BeginStr and an
EndStr variable, and I want it to return it in a char...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |