Show only two y values in a plot

조회 수: 1 (최근 30일)
Hussein Kokash
Hussein Kokash 2022년 12월 2일
댓글: Hussein Kokash 2022년 12월 2일
Hello all,
Any possible way to show only two value (0.02 and 0.04) for the y-axis, because the other values are just noise.
This is what I use for now to plot:
figure()
plot(time,wavelength,'b-x', 'LineWidth',2)
grid
axis tight
xlabel('Time')
ylabel('Wavelength')
hold on
Thank you!
  댓글 수: 9
Dyuman Joshi
Dyuman Joshi 2022년 12월 2일
Alright, did my code work? the one with ismembertol() ?
Hussein Kokash
Hussein Kokash 2022년 12월 2일
I changed the 1e-15 to 1e-10 in idx=ismembertol(wavelength,[0.033333333333333, 0.2],1e-15); and now it is working.
Thank you so much! and sorry for the trouble!
Have a great day!

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

답변 (1개)

KSSV
KSSV 2022년 12월 2일
tol = 10^-3 ; % fix your tolerance
idx = abs(wavelength-0.02)<=tol | abs(wavelength-0.04)<=tol ;
plot(time(idx),wavelength(idx),'+r')

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by