Compare on plots variables from two .mat files with same variables
8 views (last 30 days)
Show older comments
Martin Delporte
on 22 Jan 2021
Commented: Martin Delporte
on 22 Jan 2021
I would like to compare (by plot) variables of two .mat files but the two files contain the same variable names. So I cannot simply load the two files. Do I have to rename manually the variables of each file, or is there a mean to differentiate from which file a variable come from ?
0 Comments
Accepted Answer
Walter Roberson
on 22 Jan 2021
f1 = load('FirstName.mat');
f2 = load('SecondName.mat');
plot(f1.X, f1.Y, 'b', f2.X, f2.Y, 'k--'); legend({'first file', 'second file'})
Use the function form of load(), which will create a struct with one field for each variable name.
More Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT-Files 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!