Label variation in graph not following variation

조회 수: 1 (최근 30일)
Jose Cuevas
Jose Cuevas 2021년 4월 5일
답변: Anmol Dhiman 2021년 4월 7일
Hello guys, I am trying to variate my label with values of k from 0.1 to 0.9 for each line to show the dependance, but instead I always get k = 0.1. I attached the image and the data loaded in the plot function, and the code is shown below. Any help will be much appreciated.
data_name0='resultats/test_substrat.txt';
scan_trous_carres0 = importdata(data_name0);
for num_lambda=1:size_lambda
shift_lambda=(num_lambda-1)*size_pk;
for num_pk=1:size_pk
shift_pk=(num_pk-1);
A(num_pk,num_lambda)=scan_trous_carres0(1+shift_lambda+shift_pk,3);
end
end
for k = 0.1:0.9
txt = ['X = ',num2str(k)];
plot(lambda*1e6,A,'DisplayName',txt)
legend show
hold on
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 4월 5일
Try moving the legend show to after the for loop.
Jose Cuevas
Jose Cuevas 2021년 4월 5일
same result :/

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

채택된 답변

Anmol Dhiman
Anmol Dhiman 2021년 4월 7일
Hi Jose
Try using
for k=0.1:0.1:0.9
end
For more information refer for loop.
Hope it helps

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by