How do you create a script that calls variables from 2 other scripts (written as functions)?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Thomas
am 19 Feb. 2014
Beantwortet: David Sanchez
am 19 Feb. 2014
For my dissertation, I have to read in data from a csv file. I also have a function which converts date into Julian Days. How would I be able to call on these variables in a new script?
0 Kommentare
Akzeptierte Antwort
David Sanchez
am 19 Feb. 2014
you can create global variables, or better, a global struct to hold our variables.
add
global struct_for_variables % or any other name of your liking
right after the definition of your functions. Add it to your script too. Then, in your function, create a field for each variable:
struct_for_variables.var1 = var1; % where var1 is a variable to be accessed by the script or other function. you will be able to access and modify your variables from anywhere.
Another option, instead of a global struct, is to define the variables you need in the script as output parameters of your functions.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!