How do I save variables from a function to the base workspace?
405 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a matrix variable, corr_matrix. I would like to save this to the workspace without having to validate (export2wsdlg requests permission before exporting). Can you do this with evalin? I did not understand evalin's documentation...but I would like something like
Save2ws('variable_name', variable);
How can this be done?
1 Commento
Daniel Shub
il 22 Ago 2012
What you are asking for with Save2ws is a way to poof a variable. In general this is bad practice. Can you give some details about how/where corr_matrix is being created?
Risposta accettata
Ryan G
il 21 Ago 2012
4 Commenti
James Cannon
il 19 Nov 2016
Modificato: Walter Roberson
il 19 Nov 2016
in my script file: inputVT()
in my function file named inputVT.m
I have
v0 = input('velocity');
this works but my input is not stored to the workspace. How do I store it to ws?
Walter Roberson
il 19 Nov 2016
Modificato: Walter Roberson
il 19 Nov 2016
In your script,
v0 = inptuVT();
and your inputVT.m would be
function v0 = inputVT
v0 = input('velocity');
Più risposte (2)
Stacey
il 13 Gen 2020
If you would like to do this for debugging purposes, you can click on the down-arrow below "Run" and choose "Pause on Errors". This will allow you to browse the internal variables and workspace in a function in debug-mode when an error occurs.
0 Commenti
Azzi Abdelmalek
il 21 Ago 2012
Modificato: Azzi Abdelmalek
il 21 Ago 2012
declare them as global variables
global var1 var2 var3
do it in your function and in matlab command
4 Commenti
Daniel Shub
il 22 Ago 2012
@Matt while I try and avoid globals, I would never trade a global for a evalin/assignin. At least globals give you a fighting chance of figuring out what is happening.
Vedere anche
Categorie
Scopri di più su Whos 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!