Plot multiple lines in the same plot
1 次查看(过去 30 天)
显示 更早的评论
Dear all,
I am plotting in the same graph various lines and I am using hold on command. However, between the plotted lines additional lines appear linking these lines. See attached files to understand better.
How can be deleted this linking lines?
This is the code developed:
clear
clc
close all
Nmixf = 51;
mixfgrid = linspace(0,1,51);
Zst = 0.071077;
index_sDVi=2;
index_sDHi=6;
Mwrite = mixfgrid';
Mwrite(:,2) = Mwrite(:,1) + sDV(index_sDVi)*(1-Mwrite(:,1))*Zst;
temp=readmatrix('Temperature_Table_4D');
rows = any(isnan(temp),2); %delete NaN values
temp(rows,:) = [];
indices = find(abs(temp)<100);
temp(indices) = [];
N3=51;
N4=51;
N5=13;
N6=11;
for q=1:N3
for k=1:N4
n=(q-1)+N3*((k-1)+N4*((index_sDHi-1)+N5*(index_sDVi-1)))+1;
T(k)=temp(n);
Z(k)=Mwrite(k,2);
plot(Z, T,'r');
set(gca,'xlim',[0 1],'ylim',[350,2500]);
set(gca,'FontSize',12);
set(gca,'LineWidth',1.0);
set(gca,'PlotBoxAspectRatio',[1 1 1]);
xlabel('Mixture fraction','FontSize',12);
ylabel('Temperature [K]','FontSize',12);
hold on
end
end
Thank you in advance,
Kind regards,
Naiara


2 个评论
Geoff Hayes
2020-5-14
Naiara - you may need to provide some of your data so that we can reproduce the above. That being said, in these lines of code
T(k)=temp(n);
Z(k)=Mwrite(k,2);
plot(Z, T,'r');
you are updating the arrays T and Z on each iteration and then plotting all of the data in that array even that data which was drawn on previous iterations. Is that what you want to do? Or do you just want to plot the new data?
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!