i have multiple .mat file. In each file i have several matrix data with same variable name. i want to take same matrix data from each .mat file and plot . how can i do that?

1 次查看(过去 30 天)
load a_D_0.mat;
load a_D_2.mat;
load a_D_4.mat;
load a_D_6.mat;
load a_D_8.mat;
load a_D_9.mat;
col_no = [51];
legends_name = ['y / D = 0.0', 'y / D = 0.2', 'y / D = 0.4', 'y / D = 0.6', 'y / D = 0.8', 'y / D = 1.0'];
length = 4000;
depth = 50;
x_start = 1500; %15.5;
x_end = 2500; %24.5;
number_of_division = 200;
x_inrement = (x_end - x_start)/number_of_division;
x_axis = x_start:x_inrement:x_end;
x_axis_wrt_midPoint = x_axis - (length/2);
x_axis_normalized = x_axis_wrt_midPoint/depth;
figure(1);
%value = SS1' ;
temp1 = load('a_D_9.mat','SS1');
temp2_1 = SS1';
temp2 = load('a_D_0.mat','SS1');
temp1_1 = SS1';
temp2_0 = temp2_1(:,col_no);
temp1_0 = temp1_1(:, col_no);
plot(x_axis_normalized, temp1_0,'b',x_axis_normalized, temp2_0,'r');

回答(1 个)

Raj
Raj 2023-9-22
Hi Obidullah
As per my understanding, you wish to import same name matrix data from several .mat files and wish to plot them.
This is possible by using ‘load’ function and saving those data in another variable in your current workspace
Tm1= load("m1.mat","ab")
Tm2= load("m2.mat","ab")
You can later use them as per your requirement. For more information about the ‘load’ function you can refer to the documentation below
temp1 = load('a_D_9.mat','SS1');
temp2_1 = SS1';
temp2 = load('a_D_0.mat','SS1');
temp1_1 = SS1';
temp2_0 = temp2_1(:,col_no);
temp1_0 = temp1_1(:, col_no);
In your code, temp2_1 and temp1_1 has the same value and same goes with temp2_0 and temp1_0. Do check if this is what you intend on doing.

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by