Using a variable calculated in a function in the workspace
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a function which I am calling with 4 input variables.
I have a single output variable that I want to use after the function is finished.
FEM_Rechnung(D_klein, R_mitte,job,index);
to call the function and the function looks like this:
function [jobname]=FEM_Rechnung (D_klein, R_mitte, job, index)
I thought doing it this way the variable "jobname" is automatically returned to the workspace after the function is done. But I can't use it. I've seen ways with assignin or evalin but as far as I read those things come from the deepest levels of hell.
How can I use the "jobname" variable?
0 Commenti
Risposta accettata
Stephen23
il 11 Mar 2021
Modificato: Stephen23
il 11 Mar 2021
"I thought doing it this way the variable "jobname" is automatically returned to the workspace after the function is done."
Nope, nowhere in the MATLAB documentation does it state that.
"How can I use the "jobname" variable?"
Have you tried calling the function with an output argument, just like the introductory tutorials show?:
myout = FEM_Rechnung(D_klein, R_mitte,job,index);
%^^^^^^^ you need to assign the output to a variable.
Note that the names of variables used inside a function are (and should be) unrelated to the names used outside the function. You might use the same name, but that is simply coincidence and of no importance to MATLAB.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB 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!