How to find and display some value with condition?

조회 수: 1 (최근 30일)
son
son 2014년 8월 23일
댓글: Image Analyst 2014년 8월 23일
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
Image Analyst
Image Analyst 2014년 8월 23일
편집: Image Analyst 2014년 8월 23일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2014년 8월 23일
편집: Image Analyst 2014년 8월 23일
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
son
son 2014년 8월 23일
hi, if i need to find something like: 50 < z < 0.9*s
How to do it?
Image Analyst
Image Analyst 2014년 8월 23일
selectedIndexes = (z > 50) & (z < 0.9 * s);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by