Fixed plot and variable-loop plot
Show older comments
Hello everyone,
I need you help. I am trying to generate a plot with fixed lines (vertical ones) and on it, I would like to add a line that varies with the index k of a for loop that goes through a matrix. How can I avoid superimposition of all k-lines generated inside the for loop? I am trying to remove the "hold on" line but the issue is that Matlab removes the vertical lines too.
Thanks in advance for the help.
Here is the code:
assex=[0 25 25 30.7];
figure(1)
set(gcf, 'Position', get(0, 'Screensize'));
ylim([0 100]); yticks(0:2.50:100)
xticks(-1:1:35); xlim([-1 35])
xlabel('Spessore provino (cm)','FontSize',18)
ylabel('Umidità relativa aria (%)','FontSize',18)
set(gca,'FontSize',15)
grid on
xline(assex(1),'k',{'Superficie interna'});
xline(assex(2),'k',{'Freno a vapore - lato interno'},'LabelHorizontalAlignment','left');
xline(assex(3),'k',{'Freno a vapore - lato esterno'});
xline(assex(4),'k',{'Superficie esterna'});
hold on
for k=1:60:length(rh(:,1))
% scatter(assex(1,1),rh(k,1),'red','filled','SizeData',50)
% hold on
% scatter(assex(1,2),rh(k,2),'magenta','filled','SizeData',50)
% hold on
% scatter(assex(1,3),rh(k,3),'green','filled','SizeData',50)
% hold on
% scatter(assex(1,4),rh(k,4),'blue','filled','SizeData',50)
% hold on
% scatter(assex(1,:),rh(k,:),'filled','SizeData',50,'MarkerFaceColor',[0 0.4470 0.7410])
% hold on
plot(assex,rh(k,:),'LineStyle','-','Color',[0 0.4470 0.7410]);
title(string(strcat('Tempo= ',num2str(k/60,'%.2f'),' ore (',num2str(k/(60*24),'%.2f'),') giorni.')))
pause(0.0005)
end
NB: rh is a matrix with n x m dimension (index k goes along n).
Accepted Answer
More Answers (0)
Categories
Find more on Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!