How to plot variables from many m files(script files) in Mainfile.m(script file)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have Many M files say `
GAdeferrableload.m
GAnondeferrableload.m
GAinterruptibleload.m
GAnoninterruptibleload.m
GAmustrunload.m
WDO_SG_Code_PL_test1mdeferrableload.m
WDO_SG_Code_PL_test1mnondeferrableload.m
WDO_SG_Code_PL_test1minterreuptibleload.m
WDO_SG_Code_PL_test1mnoninterreuptibleload.m
WDO_SG_Code_PL_test1mmustrunload.m
GA_WDO_DeferrableLoad.m
GA_WDO_NonDeferrableLoad.m
GA_WDO_InterruptibleLoad.m
GA_WDONonInterruptibleLoad.m
GA_WDOMustRunLoad.m
and one `Mainfile.m file which are all script files and I want to plot variables of all M files in `Mainfile.m.Please any suggestion?I want to do it via .mat files.My problem is still not solved please i need more comments and help.
1 Kommentar
Stephen23
am 6 Mär. 2016
Bearbeitet: Stephen23
am 6 Mär. 2016
Duplicate of all of these:
dpb made a comment on the newsreader thread, which is worth quoting here:
"It appears your primary problem is one of data organization. Having 500 separate variables in each of some 15 separate scripts and expecting to be able to keep them all straight at one time just sounds essentially impossible (as it seems you're finding out)."
@Zafar Iqbal: your problem is your data organization. You need to organize (and store) your data much better than this. By choosing to store your data in such a an unstructured way you have made your own life very difficult. Basically the more thought you put into creating efficient data organization the easier it is to write code to solve your task.
Repeatedly asking the same question is also not going to fix your poor data organization.
Antworten (1)
Adam
am 4 Mär. 2016
Just have each file save its workspace to a matfile if that is what you want.
Then load the matfiles in the one in which you want to plot them.
I would recommend using functions and moving data around in a more controlled manner rather than a load of scripts whose workspaces are not at all self-contained, but I guess it is too late for that so simplest approach seems to be what you already suggest.
e.g.
save( 'GAdeferrableload.mat' )
in GAdeferrableload.m if you literally want to save every single variable. Otherwise you can specify the exact variables you want to save as subsequent arguments to the save function.
2 Kommentare
Adam
am 5 Mär. 2016
If you just load .mat file contents straight into the workspace then any variables with the same name as those in the workspace will obviously overwrite the existing ones.
You should use the syntax to load into a struct and/or ideally deal with each file's contents one at a time before loading the next.
Siehe auch
Kategorien
Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!