Azzera filtri
Azzera filtri

Why isn't animatedline showing a line plot?

6 visualizzazioni (ultimi 30 giorni)
Hi, I'm trying to plot an animation with 4 subplots. It is working fine except that the plots only show up if I put in a marker, not just a line.
Here is the code - can anyone advise as to how to get lines to show?
load dfRH;
load xxout;
seq = 1:6:1418;
SimT = xxout(seq,3)-273.15;
ACH = csvread('ACH_AO_1000.csv');
IAS = csvread('IAS_AO_1000.csv');
ACH_mean = mean(ACH,2)*9+1;
IAS_mean = mean(IAS,2)*0.75+0.1;
figure('WindowStyle','docked');
for k = 1:100
subplot(1,4,1)
title('Relative Humidity Data');
xlabel('timestep');
ylabel('Relative Humidity (%)');
h1 = animatedline('Marker','.','Color','b');
xlim([1,100])
ylim([0,100])
x = k;
y1 = dfRH(k,1)*100;
addpoints(h1,x,y1);
pause(0.05)
drawnow
subplot(1,4,2)
title('Ventilation Rate');
xlabel('timestep');
ylabel('Ventilation Rate (ACH)');
h2 = animatedline('Marker','o','Color','k');
xlim([1,100])
ylim([0,10])
y2 = ACH_mean(k);
addpoints(h2,x,y2);
pause(0.05)
drawnow
subplot(1,4,3)
title('Internal Air Speed');
xlabel('timestep');
ylabel('Internal Air Speed (m/s)');
h3 = animatedline('Marker','x','Color','k');
xlim([1,100])
ylim([0,1])
y3 = IAS_mean(k);
addpoints(h3,x,y3);
pause(0.05)
drawnow
subplot(1,4,4)
title('Temperature');
xlabel('timestep');
ylabel('Temperature (^oC)');
h4 = animatedline('Marker','.','Color','r');
xlim([1,100])
ylim([0,30])
y4 = SimT(k);
addpoints(h4,x,y4);
pause(0.05)
drawnow
end

Risposta accettata

Cris LaPierre
Cris LaPierre il 9 Mar 2021
Modificato: Cris LaPierre il 9 Mar 2021
I think the animatedline commands should be outside the for loop. In fact, everything except for the addpoints related code should be outside the for loop.
Here's a simple example.
ax1 = subplot(1,4,1);
h1 = animatedline(ax1);
xlim([1,100])
ylim([0,100])
title('Ventilation Rate');
xlabel('timestep');
ylabel('Ventilation Rate (ACH)');
ax2 = subplot(1,4,2);
h2 = animatedline(ax2);
xlim([1,100])
ylim([0,-100])
title('Ventilation Rate');
xlabel('timestep');
ylabel('Ventilation Rate (ACH)');
x = 1:100;
y = 50*(sin(x)+1);
for k = 1:100
ax1=subplot(1,4,1);
addpoints(h1,x(k),y(k));
drawnow
subplot(1,4,2)
addpoints(h2,x(k),-y(k));
drawnow
end

Più risposte (0)

Categorie

Scopri di più su Visual Exploration in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by