determining the greatest number
14 views (last 30 days)
Show older comments
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 Comments
Answers (2)
jonas
on 4 Oct 2018
Edited: jonas
on 4 Oct 2018
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)
0 Comments
Image Analyst
on 5 Oct 2018
Try this
[maxValue, indexOfMaxValue] = max(y);
fprintf('The max value is %.3f, and it occurs at index %d.\n', maxValue, indexOfMaxValue);
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!