How to find and display some value with condition?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!