Having a problem with MATLAB reconising variables
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
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 个评论
Image Analyst
2014-1-15
You forgot to post your error message. Please post ALL the red text, exactly as it appears. Don't snip or paraphrase.
回答(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 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!