How to find and display some value with condition?

3 visualizaciones (últimos 30 días)
son
son el 23 de Ag. de 2014
Comentada: Image Analyst el 23 de Ag. de 2014
Hi, i want to find and also display in message box all the value which is satisfied conditions:
given
x = randi(10,100,1);
y = 1:1:100;
z = y* exp(x);
s = max(z)
find all z that is z > 0.9*s and also display which x corresponds to z
please help, many thanks
  1 comentario
Image Analyst
Image Analyst el 23 de Ag. de 2014
Editada: Image Analyst el 23 de Ag. de 2014
But if z = y * exp(x); then z is a scalar for those vector shapes. So I guess the answer is that one scalar element.

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 23 de Ag. de 2014
Editada: Image Analyst el 23 de Ag. de 2014
OK, I'm going to assume you really didn't code up your problem the way you wanted to, change the code, and then offer up this solution:
clc;
x = randi(10, 1, 100);
y = 1:1:100;
z = y .* exp(x);
s = max(z)
bigZIndexes = find(z > 0.9 * s)
bigZ = z(bigZIndexes)
message = sprintf('%f\n', bigZ);
uiwait(msgbox(message));
  3 comentarios
son
son el 23 de Ag. de 2014
hi, if i need to find something like: 50 < z < 0.9*s
How to do it?
Image Analyst
Image Analyst el 23 de Ag. de 2014
selectedIndexes = (z > 50) & (z < 0.9 * s);

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by