473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

String with "

14
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?
Apr 26 '07 #1
8 1674
ghostdog74
511 Expert 256MB
try backslash, \"
Apr 26 '07 #2
lskov
14
Not working

self.matlab.Execute(\" mlab_code \")
Apr 26 '07 #3
ghostdog74
511 Expert 256MB
Not working

self.matlab.Execute(\" mlab_code \")
how about this

self.matlab.Execute("''%s'" % mlab_code)
Apr 26 '07 #4
lskov
14
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?
Apr 26 '07 #5
ghostdog74
511 Expert 256MB
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
Apr 26 '07 #6
lskov
14
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)
Apr 27 '07 #7
ghostdog74
511 Expert 256MB
if you want, you can set your argument to a default null string.eg
Expand|Select|Wrap|Line Numbers
  1. def func(mi=""):
  2.       ...
  3.       ...
  4.  
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.
Expand|Select|Wrap|Line Numbers
  1. def func(mi):
  2.       if str(mi): #make m to be string.
  3.           .....
  4.       do_somethingelse( int(m) ) #make m to be integer
  5.       try:
  6.             int(m)
  7.       except: print "cannot make to integer"
  8.       ....
  9.  
Apr 27 '07 #8
bartonc
6,596 Expert 4TB
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.
Jun 18 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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
3
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...
32
by: Indrid Colt | last post by:
Thank's for your help ! Indrid
5
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>
9
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...
10
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...
11
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",...
1
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 =...
1
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...
12
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
jinu1996
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...
0
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.