Transfering variables between Matlab Sessions
Afficher commentaires plus anciens
I have a question regarding sessions.
I have a main file with input data
I have a script called sum
I have a script called diff
sum and diff are
run on two different sessions
how do i declare 2 inputs
in main and pass them to
sum and diff???
2 commentaires
dpb
le 7 Juil 2019
If not in same session, you'll have to write the results to be saved to disk (.mat files/save/load are good for this being simple to use) and then recall them when needed.
VINAYAK KARANDIKAR
le 7 Juil 2019
Réponses (1)
Image Analyst
le 7 Juil 2019
0 votes
First of all, DO NOT name your scripts sum and diff because those are two very important built-in function names and you could run into trouble if you ever want to use the built-in functions.
Next, use save() to save variables to a .mat file, and load() to recall those variables from the file to a new session of that script or any other script.
9 commentaires
VINAYAK KARANDIKAR
le 7 Juil 2019
dpb
le 7 Juil 2019
With this and the comment in response to my earlier comment, I think we need a lot more definition of the problem to have any meaningful answer that would bear on the actual situation.
Your response to me was or at least seems to be at complete odds with the initial question conditions; when you bring parallel into the mix, "all bets are off!" with what was an initial apparent serial problem of one script following another.
VINAYAK KARANDIKAR
le 7 Juil 2019
Image Analyst
le 7 Juil 2019
Dependable as in "reliable"?
Or do you really mean "dependent", like a file or set of files depends on another file or set of files being there?
If by parallel you mean the Parallel processsing Toolbox and you have multiple workers running, then you might have to pass stuff in memory and handle any timing/race issues.
VINAYAK KARANDIKAR
le 8 Juil 2019
Image Analyst
le 8 Juil 2019
Yes, that's dependent and dependency. Dependable is en entirely different word, it means like you can count on a person as being reliable and loyal.
So why don't you just pass the variables from the main function to the second function via the functions argument list? This is just standard function usage like everybody knows and uses all the time. You can't get far in MATLAB without learning how to call functions. I think it should have been on the 2 hour training.
VINAYAK KARANDIKAR
le 8 Juil 2019
Image Analyst
le 8 Juil 2019
Then why not just transfer things via .mat files?
I guess we don't understand and maybe if you call tech support they can suggest a solution.
VINAYAK KARANDIKAR
le 8 Juil 2019
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!