Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
soloby
soloby le 23 Juin 2015
Commenté : Walter Roberson le 25 Juin 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).

Réponses (1)

Walter Roberson
Walter Roberson le 23 Juin 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 commentaires
soloby
soloby le 23 Juin 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 le 25 Juin 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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Elementary Math dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by