MATLAB Array Manipulation: Finding Smallest and Largest Values, Exercises of Signals and Systems Theory

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

2011/2012

Uploaded on 07/14/2012

kapor
kapor 🇮🇳

4

(1)

37 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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
docsity.com

Partial preview of the text

Download MATLAB Array Manipulation: Finding Smallest and Largest Values and more Exercises Signals and Systems Theory in PDF only on Docsity!

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

docsity.com