Please help extract variables from mat files and plot

Please help,
I have two .mat files (sit1.1 & site1.2 attached) containing different variables., rhoxy, rhoyx, zxy, zyx, freq, etc.
I want to load this two files and plot, for example extract values for rhoxy vs freq from each file and plot in a single plot.
Thanks!

 採用された回答

A. Sawas
A. Sawas 2019 年 4 月 8 日

0 投票

load('site1.1.mat');
site1 = site;
load('site1.2.mat');
site2 = site;
figure;
plot(site1.freq, site1.zxy, 'DisplayName', 'Site 1'); hold on;
plot(site2.freq, site2.zxy, 'DisplayName', 'Site 2');
xlabel('Freq');
ylabel('zxy');
legend show;

4 件のコメント

Calistus Ramotoroko
Calistus Ramotoroko 2019 年 4 月 9 日
Thanks a lot Adam & Sawas.
Adam Danz
Adam Danz 2019 年 4 月 9 日
I would add one small improvement. By specifying what variable(s) to load, you minimize the risk of loading a bunch of unneeded variables that could overwrite existing variables.
site1Struc = load('site1.1.mat', 'site');
site1 = site1Struc.site;
site2Struc = load('site1.2.mat', 'site');
site2 = site2Struc.site;
Calistus Ramotoroko
Calistus Ramotoroko 2019 年 4 月 9 日
Thanks for the additional help Adam. I'm learning a lot from you guys.
ELLER JUCO
ELLER JUCO 2022 年 9 月 5 日
what if the variables under different site have same name?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by