Matlab function Will not work
8 views (last 30 days)
Show older comments
Hey guys, I have a function I'm creating and u want to assign values to the input but so far it's working. Function myname=myfunc( al,la,Li,ti) Now the values I want to pass to al, la, Li,ti are included in a .bat file I open the file
File=textread('input.bat','%s','delimiter','\n','whitespace','');
%Then grab the string value and pass it to the function input
al=file(2,:)
La=file(3,:)
and so on Then I open and .exe file and pass the input to it from that my batch file
Sysem('my file.exe< input.bat')
That line was the only line that I need to make my program works. But what I want to is to do is instead of having the value of al,la, Li, to to just print on the screen when I call the .exe file, I want to capture those values and plot them later if I want. So far I get the error that the input arguments appear to never be used. Can anybody help me because I tried everything?
0 Comments
Answers (3)
Jason Ross
on 4 Feb 2013
In the code above, you have "File" and "file" as your variable names. Is this a typo, or does the case really vary in your code?
Jason Ross
on 4 Feb 2013
If you set a breakpoint when the file is being read and step through, do the variables contain anything? As you step, you should be able to see the values change by hovering on the variable.
If you try using ".txt" as the file ending, does that change anything? On Windows, a .bat file has a specific meaning, so Windows could get confused later making a differentiation between the .bat and .txt file. Given the way you are using the file, it's not a batch file, it's just text.
It would also be good to look at the variable types that you get -- are they the types you expect them to be?
Image Analyst
on 4 Feb 2013
You say "the values I want to pass to al, la, Li,ti are included in a .bat file" and then you want to, or try to, read this .bat file into MATLAB. Evidently from your m-file code, you think input.bat already has the value in it that are needed. But you don't really do anything with the file after your read it in. Why not? Why did you read it in in the first place???
Then you run your executable taking inputs from this input.bat file (which you never did anything with). Your line of thinking is a total mystery to me.
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!