Hi, I want to plot around 30 graphs using for loop
이전 댓글 표시
So I'm trying to plot multiple graphs including multiple plots each using a for loop, it takes data from many matrices and plot them, the problem is that I only get one plot instead of 30, I don't get why here is my code:
for i=4:33
rpm=DataBFE{2,3}.OscillationAngle.data(:,1);
plot(rpm,Ref_model_value_2nd,'k')
hold on
plot(rpm,Ref_model_value_4th,'r')
plot(rpm,Ref_model_value_6th,'g')
plot(rpm,Ref_model_value_8th,'y')
plot(rpm,Ref_model_value_10th,'c')
plot(rpm,comb_models_values_2nd(i-3),'k','LineStyle','--')
plot(rpm,comb_models_values_4th(i-3),'r','LineStyle','--')
plot(rpm,comb_models_values_6th(i-3),'g','LineStyle','--')
plot(rpm,comb_models_values_8th(i-3),'y','LineStyle','--')
plot(rpm,comb_models_values_10th(i-3),'c','LineStyle','--')
%title('BigEnd -10 -10 -10 -10')
ylim([0 0.5])
xlabel('RPM')
ylabel('Osciallation angle')
hold on
legend('2nd order','4th order','6th order','8th order','10th order')
end
댓글 수: 6
David Hill
2022년 9월 9일
Inspect the data in your variables to make sure the data is there and makes sense.
Mhamad Hantro
2022년 9월 9일
If I understand you correctly, you want several plots with each loop being a plot by itself. If this was the case, using 'plot' doesn't open a new window for a new plot, you need to use the command 'figure' at the begining of each loop.
David Hill
2022년 9월 9일
There is nothing wrong with the plot command, there is a problem with your data. You need to inspect your data.
Simon
2022년 9월 9일
Of course. Use <See title documentation>. You have to have some way to programmatically define what the title string is going to be.
Jan
2022년 9월 10일
@Simon: By the way, this is not twitter: no # before the tags.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!