Plot multiple lines in the same plot

조회 수: 3 (최근 30일)
Naiara Romero Anton
Naiara Romero Anton 2020년 5월 13일
편집: Naiara Romero Anton 2020년 5월 14일
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일
편집: 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