How to not draw some points of an interval( hmax and hmin )
Ältere Kommentare anzeigen
I have this function but i have to finish it. I have to say to matlab to not draw the points of the graph between hmax and hmin Can someone help me???
h = max(y); hmax = (percT/100)*h; hmin = (percB)/100*h;
for i=1:size(y,1) if y(i)> hmax y(i) = hmax; else if y(i)< hmin y(i) = hmin;
else.....how i have to finish???
Many thanks in advance!!!
Antworten (1)
Jonathan LeSage
am 14 Okt. 2013
You can use logical indexing to remove any values greater than and less than the desired bounds.
% Defining some arbitrary data
x = 0:0.05:2*pi;
y = sin(x);
% Defining some arbitrary bounds
hmax = 0.5;
hmin = -0.5;
y_bounded = y;
% Using logical indexing to replace all values > hmax with NaN
% When plotting, MATLAB ignores values that are defined as NaN
y_bounded(y_bounded > hmax) = NaN;
y_bounded(y_bounded < hmin) = NaN;
% Plot Results
plot(x,y,x,y_bounded,'o');
grid on;
legend('Orignal Data','Bounded Data');
Hope this helps!
1 Kommentar
Antonella
am 15 Okt. 2013
Kategorien
Mehr zu Interpolation of 2-D Selections in 3-D Grids finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!