Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

How to resolve this error ?From GUI executing simulink model

Asked by Arun Badigannavar on 4 Dec 2012

I am executing a simulink model from gui, and in in the simulink model i have four blocks which send data to workspace,,,am getting thisa error,,how to overcome this?

Error using FinalTest/pushbutton2_Callback (line 41) Cannot create variable 'speed' in workspace

Caused by: Error using FinalTest/pushbutton2_Callback (line 41) Attempt to add "speed" to a static workspace. See MATLAB Programming, Restrictions on Assigning to Variables for details.

Error while evaluating uicontrol Callback

0 Comments

Arun Badigannavar

Tags

Products

2 Answers

Answer by Jonathan Epperl on 4 Dec 2012
Accepted answer

As your error states, you are trying to add a variable to a workspace that doesn't want you to. The workspace is likely the workspace of the calling function in your GUI, it is not the base workspace.

The functions evalin and assignin might be of use, the easiest workaround would probably be to write to a file instead a workspace variable.

1 Comment

Arun Badigannavar on 4 Dec 2012

Thank you its working out now,,,,

Jonathan Epperl
Answer by Walter Roberson on 4 Dec 2012
Accepted answer

Something you are doing is attempting to "poof" a variable into existance -- that is, attempting to execute a command such as eval() or evalin() or load() with no outputs, which creates a variable without an explicit assignment statement having appeared for the variable. Or, you are trying to run a script from within a function and the script tries to assign values. In some kinds of functions (the better kind), that is an error. The best solution is not to poof at all. In the case of scripts being run from functions, rewrite the scripts as functions that return the values back, or at the very least assign every variable a value before running the script.

1 Comment

Arun Badigannavar on 4 Dec 2012

Thanks for your response

Walter Roberson

Contact us