Referencing variables in the workspace
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aditya
am 6 Nov. 2014
Kommentiert: Chad Greene
am 7 Nov. 2014
Hello all,
I am using a script which accesses an mdf file and then stores the channels chosen into arrays/mat in matlab. While it does this, it adds extensions to the end of the channel name ex: Engine_speed_24. I can see this variable in the workspace. I want to know is there a way of accessing or referencing these variables which are generated by an external script/function in my main code? I need to plot these variables but I don't want to type in the name of the variable each time, as the extension might change if the channel changes.
Ex - Channel names - Engine_speed, Engine_torque. Run func -> extracts these channels from mdf file -> stores variables as Engine_speed_XX and Engine_torque_YY, time_XX and time_YY
I need a way to plot them against time as I don't know what the extensions might be.
Thanks
2 Kommentare
Image Analyst
am 6 Nov. 2014
What is the extension? If it's .mdf, that's not going to change depending on what's inside, since you can't know what's inside until you actually open the .mdf file. So is the extension the "_24"? Or something else? Since you have access to the m file, it's best if you have it return a variable with the same name each time rather than do whatever it does to make variable names that are dependent on something in the file.
Akzeptierte Antwort
Chad Greene
am 6 Nov. 2014
Does this help?
x = 1;
y = 2;
s = who;
s(1)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos 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!