Filter löschen
Filter löschen

getting min and max for different y-values of a graph

1 Ansicht (letzte 30 Tage)
soloby
soloby am 23 Jun. 2015
Kommentiert: Walter Roberson am 25 Jun. 2015
x = -10:0.1:10;
f1 = trapmf(x,[-2 0 0 2]);
I need to find min(x),max(x) for 201 different f1 values
since my f1 ranges from 0 to 1 in this built in function
@ f1 = 0, I need a min(x), max(x)
@ f1 = 0.05, min(x), max(x)
..
all the way upto
@f1 = 1, min(x), max(x).

Antworten (1)

Walter Roberson
Walter Roberson am 23 Jun. 2015
testlocs = 0:0.05:1;
t = bsxfun(@ge, f1(:), testlocs);
for K = 1 : size(t, 1)
minidx = find(t(K,:), 1, 'first');
maxidx = find(t(K,:), 1, 'last');
minx(K) = testlocs(minidx);
maxx(K) = testlocs(maxidx);
end
  2 Kommentare
soloby
soloby am 23 Jun. 2015
i'm sorry I dont follow your coding, what is minx? it gives me a 1x201 matrix with all 0's.
Walter Roberson
Walter Roberson am 25 Jun. 2015
testlocs = 0:0.05:1;
t = bsxfun(@le, testlocs(:), f1(:)');
for K = 1 : size(t, 1)
minidx = find(t(K,:), 1, 'first');
maxidx = find(t(K,:), 1, 'last');
minx(K) = testlocs(minidx);
maxx(K) = testlocs(maxidx);
end

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by