hi,
I need to insert a legend for each ii evalueted.
giri can change in size at every simulation.
for ii=1:length(giri)
figure(3);
plot(m(indice_m_0:loc(ii)),psic_pos(ii,indice_m_0:loc(ii)));
grid on
hold on
end

답변 (1개)

Shubham Gupta
Shubham Gupta 2019년 11월 11일

1 개 추천

Try :
for ii=1:length(giri)
figure(3);
plot(m(indice_m_0:loc(ii)),psic_pos(ii,indice_m_0:loc(ii)),'DisplayName',['ii = ',num2str(ii)]);
grid on
hold on
end
legend show

댓글 수: 5

Paul Rogers
Paul Rogers 2019년 11월 11일
so and so.
It displays the index not the value of the ii element.
I would like to display N=values
Walter Roberson
Walter Roberson 2019년 11월 11일
편집: Walter Roberson 2019년 11월 11일
figure(3);
for ii=1:length(giri)
plot(m(indice_m_0:loc(ii)),psic_pos(ii,indice_m_0:loc(ii)),'DisplayName',['giri = ',giri(ii)]);
grid on
hold on
end
legend show
Paul Rogers
Paul Rogers 2019년 11월 11일
yes, but I don't know why, instead of the ii-value it shows chines letters.
I attached the file.
figure(3);
for ii=1:length(giri)
plot(m(indice_m_0:loc(ii)),psic_pos(ii,indice_m_0:loc(ii)),'DisplayName',sprintf('giri = %g',giri(ii)));
grid on
hold on
end
legend show
Change the %g format to whatever you need.
TADA
TADA 2019년 11월 11일
probably because of an implicit conversion from double to char
maybe this would work:
plot(m(indice_m_0:loc(ii)),psic_pos(ii,indice_m_0:loc(ii)),'DisplayName',['giri = ', num2str(giri(ii))]);
next time it would be better if you attach the data, without sample data helping you is pretty much guesswork...

댓글을 달려면 로그인하십시오.

카테고리

질문:

2019년 11월 10일

댓글:

2019년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by