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
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?
Naiara Romero Anton
编辑:Naiara Romero Anton 2020-5-14
Dear Geoff,
Thank you for your answer. In the lines of the code that you mention I just want to plot the new data, but if I write the next lines, nothing is drawn in the graph. In the next link you can download Temperature_Table_4D file: https://we.tl/t-q8778uZdWJ
T(k)=temp(n);
Z(k)=Mwrite(k,2);
plot(Z(k), T(k),'r');
Additionally, the following code is missing (this goes after close all):
sDV = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1]; %se definen los valores de dilución
sDH = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.85 0.9 0.95 1]; %se definen los valores de enthalpy loss
PV=linspace(0,1,51);
Thank you in advance,
Kind regards,
Naiara

请先登录,再进行评论。

回答(0 个)

类别

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

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by