0% found this document useful (0 votes)
30 views10 pages

'Blastoff!': While

The document contains multiple MATLAB code snippets demonstrating the use of loops, arrays, conditionals, and other programming concepts. It includes for loops counting down from 3 to 1, nested for loops printing a string 10 times with increments of 0.1 from 0 to 1, summing the element-wise product of two arrays, incrementing values in an array based on a for loop, using a while loop to increment a value until it exceeds 100, printing "Hello World" 50 times using a for loop, decrementing a counter variable in a for loop, using a for loop to print a string counting down from -1 to -50, using a switch conditional to print strings for different input values, and using a for loop to print

Uploaded by

Hira Khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views10 pages

'Blastoff!': While

The document contains multiple MATLAB code snippets demonstrating the use of loops, arrays, conditionals, and other programming concepts. It includes for loops counting down from 3 to 1, nested for loops printing a string 10 times with increments of 0.1 from 0 to 1, summing the element-wise product of two arrays, incrementing values in an array based on a for loop, using a while loop to increment a value until it exceeds 100, printing "Hello World" 50 times using a for loop, decrementing a counter variable in a for loop, using a for loop to print a string counting down from -1 to -50, using a switch conditional to print strings for different input values, and using a for loop to print

Uploaded by

Hira Khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

i = 3

while i > 0
disp(i)
i = i - 1;
end
disp('Blastoff!')

i=

Blastoff!
for a=10:10:50
for b=0:0.1:1
disp('sir syed university of engineering & technology')
end
end

sir syed university of engineering & technology


sir syed university of engineering & technology
sir syed university of engineering & technology
sir syed university of engineering & technology
sir syed university of engineering & technology
sir syed university of engineering & technology
sir syed university of engineering & technology
sir syed university of engineering & technology

sir syed university of engineering & technology


sir syed university of engineering & technology
sir syed university of engineering & technology
sir syed university of engineering & technology
sir syed university of engineering & technology
r =
c =
sum
for
end

[9 4 0];
[8 7 5];
= 0;
i = 1:3 % The counter is i, and the range is 1:3
sum = sum + r(i) * c(i) % This will be executed 3 times

sum =

72

sum =

100

sum =

100
P=10;
G=4;
X=[6 zeros(1,P-1)];
for K=2:P
X(K)= X(K-1)+G
end

X=

10

10

14

10

14

18

10

14

18

22

10

14

18

22

26

X=

X=

X=

X=

Z=4;
L=3;
while 1
Z=Z+L
if Z>100,break,end
end

Z=

Z=

10

Z=

13

Z=

16

Z=

19

Z=

22

Z=

25

Z=

28

Z=

31

Z=

34
Z=90;
L=3;
while 1
Z=Z+L
if Z>100,break,end
end

Z=

93

Z=

96

Z=

99

Z=

102
for a=0:50
disp('Hello World')
end

Hello World
Hello World
Hello World
Hello World
Hello World

Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
n = 10;
for j = 1:n
n = n-1;
j
end

j=

j=

j=

j=

j=

j=

j=

7
for a=-1:-1:-50
disp('communication system')
end

communication system
communication system

communication system
communication system
communication system
communication system
communication system
communication system
communication system
communication system
n = input('Enter a number: ');
switch n
case -1
disp('negative one')
case 0
disp('zero')
case 1
disp('positive one')
otherwise
disp('other value')
end

Enter a number: -1
negative one
Enter a number: 0
zero
Enter a number: 1
positive one
>> 9

ans =

9
for a=0:30
disp('SIGNAL & SYSTEMS')

end

SIGNAL & SYSTEMS


SIGNAL & SYSTEMS
SIGNAL & SYSTEMS
SIGNAL & SYSTEMS
SIGNAL & SYSTEMS
SIGNAL & SYSTEMS
SIGNAL & SYSTEMS
SIGNAL & SYSTEMS
SIGNAL & SYSTEMS
SIGNAL & SYSTEMS

You might also like