Filter löschen
Filter löschen

Show only two y values in a plot

4 Ansichten (letzte 30 Tage)
Hussein Kokash
Hussein Kokash am 2 Dez. 2022
Kommentiert: Hussein Kokash am 2 Dez. 2022
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 Kommentare
Dyuman Joshi
Dyuman Joshi am 2 Dez. 2022
Alright, did my code work? the one with ismembertol() ?
Hussein Kokash
Hussein Kokash am 2 Dez. 2022
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!

Melden Sie sich an, um zu kommentieren.

Antworten (1)

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

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by