
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A matlab code example that demonstrates how to find the smallest and largest values in an array using the sort function. The code is followed by an explanation of how to input the size of the array and initialize it with zeros and ones.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

clear clc a=[2 5 7 9 4 12 5 0 -5 2]; b=sort(a); disp('Smallest value in array= ') b(1,1) disp(' ') z=length(b); disp('Greatest value in array= ') b(1,z) clear clc n=input ('enter the value of n= ') n=n*2; for x=1:2:n a(x)=1; end for x=2:2:n a(x)=0; end a