#Day9- #100DaysChallenge- Matlab Loops| Find the greatest Value in the given Vector
#Day9- Find the greatest Value in the given Vector
Task:Find the Greatest Value in the given VectorNote: This code can be done using the in-built command. But for the challenge, I am trying to avoid those
x=[4,5,6,7,8,9,99,101,101,1000];
Greatest Value=1000;
Matlab Code:
function greater_x=find_greater(x)
greater_x=1;
for i=1:1:length(x)
if greater_x>x(i)
else
greater_x=x(i);
end
end
Sample Input and output:
x1=[250,3,4,5,60,70,80];
greater_x =
250
x2=[4,5,7,70,90,5,6,7];
greater_x =
90
Join us on Telegram: https://t.me/matlabirawen
Join us on Facebook Group: https://www.facebook.com/groups/matlabcodes
No comments