m file is not reading variables from the workspace
Show older comments
Hello,
I'm having problems with my script, it doesn't want to read the variables from the workspace. I tried several things, among them evalin and it still doesn't work. I don't want to have to copy the data and physically paste it to the script, does anybody knows how to solve this problem? I keep getting the error current has not been assigned, although the variable current is in the workspace already (this variable was created by another file). How can I call current from the workspace so the m file can read the variable?
Here is a short version of my file and I'm omitting the equations as they are pretty long.
Jphotototal=current(1,:); plot(lambda,Jphotototal,'ro'); hold on L0=[0.1 0.1]; options = optimset ('Maxiter',1000,'tolfun',1e-20,'TolX',1e-20,'MaxFunEvals',1000); L=lsqnonlin('recfun',L0,0,400,options);
Thanks, Francisco
2 Comments
Chirag Gupta
on 14 Jul 2011
Ensure that its a script and not a function.
Francisco
on 14 Jul 2011
Accepted Answer
More Answers (3)
Walter Roberson
on 14 Jul 2011
0 votes
"current" is probably being defined in the workspace of a different function, unless that other function is using assignin('base',...)
1 Comment
Francisco
on 14 Jul 2011
Francisco
on 14 Jul 2011
0 votes
Hello Gupta,
I tried to use the instruction
variableName_in_myFunction = evalin('ws', variableName_in_workspace);
the instruction doesn't work in the simulation in Simulink. Here the error that I had when I try to run the simulation : Error evaluating registered method 'Outputs' of M-S-Function myFunction in mySimulinkModel. Undefined function or variable variableName_in_myFunction.
Does someone had this error?
Would you please want to help me?
Thank you in advance and your collaboration.
Lamine
Categories
Find more on Workspace Variables and MAT Files 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!