Matlab function Will not work

2 views (last 30 days)
Mini Me
Mini Me on 4 Feb 2013
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?

Answers (3)

Jason Ross
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
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?
  1 Comment
Mini Me
Mini Me on 5 Feb 2013
I call the exe file with the input file. So the eve file take the input from the file as output the results on the screen. But that's juts plainly vague. Because I want to go bck to the command prompt and call one of the inputs it will give me an error because they were never declared in Matlab. I want to grab those inputs from the file and have them just in case I want call them again or run a Plot of them. That's is why I was trying to write a function that opens the file, grab those inputs then call the exe file and the input file. I'm not sure if that make sense or not

Sign in to comment.


Image Analyst
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.
  1 Comment
Mini Me
Mini Me on 4 Feb 2013
I call the exe file with the input file. So the eve file take the input from the file as output the results on the screen. But that's juts plainly vague. Because I want to go bck to the command prompt and call one of the inputs it will give me an error because they were never declared in Matlab. I want to grab those inputs from the file and have them just in case I want call them again or run a Plot of them. That's is why I was trying to write a function that opens the file, grab those inputs then call the exe file and the input file. I'm not sure if that make sense or not

Sign in to comment.

Categories

Find more on Graphics Object Identification 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!