Having a problem with MATLAB reconising variables
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I have two MATLAB files in my diretory, one is a list of variables, the other is an fsolve script which uses the variables from the previous script. I execute the the list of variables files so that the list of variables is in the workspace, but when I try and run my function file MATLAB says that the variables are undefined. Can anybody help?
1 Comment
Image Analyst
on 15 Jan 2014
You forgot to post your error message. Please post ALL the red text, exactly as it appears. Don't snip or paraphrase.
Answers (1)
Your function has no idea of what's in your workspace. You need to pass these variables to the function if you want it to be able to see them. For that you could simply run the script inside your function:
function [bla] = your_fun(something)
myscript.m %Tada!!!
do your thing
end
For the sake of completeness, I should say that you could also declare them as globals. But that's always a terrible idea.
1 Comment
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!