why any function as m file, does not work on my pc?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
saeede soleymani
il 25 Nov 2015
Commentato: saeede soleymani
il 26 Nov 2015
I have MATLAB2014a 32bit on my pc with windows8 64bit. I wrote an m file (function), but it didn't work and had error. after, I write a so easy m file, and has error!!!!! what should I do?
function y=new_state(x,v)
y=x+v
end
error is
Error using new_state (line 2)
Not enough input arguments.
0 Commenti
Risposta accettata
Walter Roberson
il 25 Nov 2015
If you run Simulink from the GUI menu, then variables for To Workspace blocks go in to the base workspace.
If you run Simulink by using the sim() command, then variables for To Workspace blocks go in to the workspace of the function that you call sim() in.
If you need to pull a variable out of the base workspace you can do that using evalin()
a = evalin('base', 'a');
b = evalin('base', 'b');
new_state(a, b);
Più risposte (1)
Ilham Hardy
il 25 Nov 2015
And did you call that with two arguments?
new_state(2,3)
2 Commenti
Ilham Hardy
il 25 Nov 2015
Say you have variable a and b in the base workspace, then you can call
y = new_state(a,b);
If you want to call the new_state from within the function, you do not have direct access to the base workspace.
Perhaps it will best for you to open new question thread and better formulate your question (with more examples)?
Vedere anche
Categorie
Scopri di più su General Applications in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!