I need help please, I'm trying to make each execution of the set command to be done in a subplot

11 views (last 30 days)
At this moment all the graphs are made in a single figure but I cannot make each graph be made in a different window (it must be done with the set command)
tmax = 60; % tiempo de captura en s
rate = 33; % resultado experimental (comprobar)
l1 = line(nan,nan,'Color','r','LineWidth',2);
l2 = line(nan,nan,'Color','b','LineWidth',2);
l3 = line(nan,nan,'Color','c','LineWidth',2);
v1 = zeros(1,tmax*rate);
v2 = zeros(1,tmax*rate);
v3 = zeros(1,tmax*rate);
i = 1;
t = 0;
tic
while t<tmax
t = toc;
% leer del puerto serie
a = fscanf(s,'%d,%d,%d')';
v1(i)=a(1);
v2(i)=a(2);
v3(i)=a(3);
x = linspace(0,i/rate,i);
set(l1,'YData',v1(1:i),'XData',x);
set(l2,'YData',v2(1:i),'XData',x);
set(l3,'YData',v3(1:i),'XData',x);
drawnow
i = i+1;
end

Answers (1)

Cris LaPierre
Cris LaPierre on 5 Jun 2023
You need to plot your lines in separate figures then.
l1 = line(nan,nan,'Color','r','LineWidth',2);
figure
l2 = line(nan,nan,'Color','b','LineWidth',2);
figure
l3 = line(nan,nan,'Color','c','LineWidth',2);
% now add data using the line handles
x = 1:5;
y1 = rand(5,1);
y2 = rand(5,1);
y3 = rand(5,1);
set(l1,'YData',y1,'XData',x);
set(l2,'YData',y2,'XData',x);
set(l3,'YData',y3,'XData',x);

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!