필터 지우기
필터 지우기

Problem with multiple values on plot

조회 수: 1 (최근 30일)
Catherine
Catherine 2017년 2월 28일
댓글: David Goodmanson 2017년 2월 28일
Hi guys, I am having problem with repeated values on my plot.
Here is my code regarding the plot:
plot(L_value,Temp_Lfile)
title('Intensity profile','fontsize',18)
xlabel('Wavelength (nm)','fontsize',18)
ylabel('Intensity','fontsize',18)
set(gca,'fontsize',18)
[L_pks,L_locs] = findpeaks(Temp_Lfile);
L_val = L_value(L_locs);
text(L_val,L_pks,num2str(L_val),'fontsize',12);
Both my L_val and L_pks variables are only 1x8 matrix. So, there should only be 8 numbers on the plot. Which part of my code is incorrect?
Thanks guys!
  댓글 수: 2
KSSV
KSSV 2017년 2월 28일
Have you tried with [L_pks,L_locs] = findpeaks(L_value,Temp_Lfile); ?
Catherine
Catherine 2017년 2월 28일
Hi KSSV, thanks for your reply. Here is the error message if I did what you suggested:
Error in findpeaks (line 59)
[X,Ph,Pd,Th,Np,Str,infIdx] = parse_inputs(X,varargin{:});
Error in Simulation_L_fix_mica (line 86)
[L_pks,L_locs] = findpeaks(L_value,Temp_Lfile);

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

채택된 답변

David Goodmanson
David Goodmanson 2017년 2월 28일
편집: David Goodmanson 2017년 2월 28일
Hello Catherine, The last line will probably work if changed to
text(L_val,L_pks,num2str(L_val'),'fontsize',12);
this is because num2str of a row vector is one long string, which gets reused every time. num2str of a column vector is a column matrix of shorter strings, so text cycles through them.
  댓글 수: 2
Catherine
Catherine 2017년 2월 28일
Indeed! It worked perfectly! Thanks heaps David!
David Goodmanson
David Goodmanson 2017년 2월 28일
you're welcome; it's good to hear that it worked.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by