How to plot a figures consisting of data of two different scripts
8 views (last 30 days)
Show older comments
I have a lot of data originating from different folders. I'm testing specimens of carbon epoxy and thus each specimen has its own folder containing the matlab script with the data processing.
I have to plot figures to compare the specimens in certain properties and their evolution in time. Yet since they're not in the same folder or as my script uses the same names for the variables in both scripts I do'nt know how to plot them together.
Any advice is welcome !
0 Comments
Answers (3)
Star Strider
on 6 May 2017
Edited: Star Strider
on 6 May 2017
First, save them in each script as ‘.mat’ files. You can then load them both in the script you want to use to plot them.
You can solve the problem of the variables having the same names by using load with an output argument:
D1 = load('first_file.mat');
D2 = load('second_file.mat');
The outputs are structures, so you can assign different variable names (or cell or numeric array variables) to the variables in each file:
x1 = D1.x;
y1 = D1.y;
x2 = D2.x;
y2 = D2.y;
Image Analyst
on 6 May 2017
Hopefully each of the different scripts is the same so that it processes the data in each folder exactly the same way, and the only reason you have different scripts is because the author didn't know how to use things like fullfile() to create filenames of files that are in different folders than the m-files. Hopefully each script doesn't do something totally different/unique. If the same functions are being applied to each set of data in the different folders, you can just build an m-file where the script is now a function that gets called on each of the different folders or files within the folders. Now, with R2016b you can use dir with two to recursively "visit" all files in all subfolders. See attached demo, as well as a demo if you have an old version of MATLAB where you'll have to use genpath.
0 Comments
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!