How to subplot inconsistent data in the loop?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I am using the code below to plot the data ussing subplot, but the data is inconsistant and I am getting the error below. Can you guys help.
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in ABCD_HeadTimeStamps (line 22)
xm = [x x1 x2 x3];
Code:
files = ['F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_D\Data_Head\Data_Raw\LaserSheet.xlsx'];
a = readtable(files);
x = a{:,3};
y = a{:,15};
files = ['F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_C\Data_Head\Data_Raw\LaserSheet.xlsx']
a = readtable(files);
x1 = a{:,3};
y1 = a{:,15};
files = ['F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_B\Data_Head\Data_Raw\LaserSheet.xlsx'];
a = readtable(files);
x2 = a{:,3};
y2 = a{:,15};
files = ['F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_A\Data_Head\Data_Raw\LaserSheet.xlsx'];
a = readtable(files);
x3 = a{:,3};
y3 = a{:,15};
% after obtaining the data, concatenate it into matrices
xm = [x x1 x2 x3];
ym = [y y1 y2 y3];
sheetlabel = 'DCBA'
figure(1)
for j = 1:4
subplot(2,2,j)
plot(xm(:,j),ym(:,j),'*')
%Spacing and griding
xlim([0 6])
ylim([0 600])
hold on
grid on
% Design Head
yy = 500;
line ([0,500],[yy,yy],'color','k','LineWidth',1);
txt = {'Design Head = 500 mm'};
text(1,560,txt)
xx = 5;
line ([xx,xx],[0,500],'color','k','LineWidth',1);
%Chart Representation
title(['DataLaserSheet-',sheetlabel(j)]);
xlabel('flowrate (l/s)');
ylabel('Head (mm))');
hold off
end
sgtitle('Outlet-110 mm')
0 commentaires
Réponse acceptée
KSSV
le 17 Jan 2022
Modifié(e) : KSSV
le 17 Jan 2022
The dimensions of x, x1, etc are not same to join them.
% Demo
x = rand(2,1) ;
x1 = rand(4,1) ;
x2 = rand(3,1) ;
x =[x x1 x2]
You may consider the folloing code:
files = cell(4,1) ;
files{1} = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_D\Data_Head\Data_Raw\LaserSheet.xlsx';
files{2} = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_C\Data_Head\Data_Raw\LaserSheet.xlsx';
files{3} = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_B\Data_Head\Data_Raw\LaserSheet.xlsx';
files{4} = 'F:\3-PIV_Experimental_Data\Outlet_110\Data_LaserSheet_A\Data_Head\Data_Raw\LaserSheet.xlsx';
figure(1)
for j = 1:4
a = readtable(files{j});
x = duration(a.(3));
y = a.(15);
subplot(2,2,j)
plot(x,y)
%Spacing and griding
xlim([0 6])
ylim([0 600])
hold on
grid on
% Design Head
yy = 500;
line ([0,500],[yy,yy],'color','k','LineWidth',1);
txt = {'Design Head = 500 mm'};
text(1,560,txt)
xx = 5;
line ([xx,xx],[0,500],'color','k','LineWidth',1);
%Chart Representation
title(['DataLaserSheet-',sheetlabel(j)]);
xlabel('flowrate (l/s)');
ylabel('Head (mm))');
hold off
end
sgtitle('Outlet-110 mm')
4 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!