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

1 visualización (últimos 30 días)
soloby
soloby el 23 de Jun. de 2015
Comentada: Walter Roberson el 25 de Jun. de 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).

Respuestas (1)

Walter Roberson
Walter Roberson el 23 de Jun. de 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 comentarios
soloby
soloby el 23 de Jun. de 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 el 25 de Jun. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Elementary Math en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by