determining the greatest number

I have to work on signal power levels. Suppose if I have a receiver that is taking signals from some items. Each signal has a different power level how does the receiver determine which signal has a greatest signal.
I am trying to write a code in matlab by starting to generate 5 random variables but how do I put in loop so that the output y shows the highest number value???

댓글 수: 3

jonas
jonas 2018년 10월 4일
Show an example.
Archita Keni
Archita Keni 2018년 10월 4일
suppose if I have rand(1,5) how should i write program that determines which out the random number is the largest number
y=rand(1,5)
max(y)

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

답변 (2개)

jonas
jonas 2018년 10월 4일
편집: jonas 2018년 10월 4일

0 개 추천

Read about the max function
You do not need to make a loop, and it is faster to work with vectors. If you want to take the random out of five samples, and repeat this n times, then it is faster to create a nx5 array and tell the max-function to operate along the 2nd dimension (columns)
y = rand(n,5)
max(y,[],2)
Image Analyst
Image Analyst 2018년 10월 5일

0 개 추천

Try this
[maxValue, indexOfMaxValue] = max(y);
fprintf('The max value is %.3f, and it occurs at index %d.\n', maxValue, indexOfMaxValue);

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2018년 10월 4일

답변:

2018년 10월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by