Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

#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 Vector

Note: 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

Click Here for Video Description:





Join us on Telegram: https://t.me/matlabirawen
 Join us on Facebook Group: https://www.facebook.com/groups/matlabcodes

No comments

Popular Posts