0% found this document useful (0 votes)
62 views

All All

The document contains the output of running multiple code snippets in MATLAB. It defines various arrays and matrices, performs operations on them like addition, multiplication and element-wise multiplication, and displays the results. For example, it defines matrices a, b, c, sets a scalar d, performs operations like a+b, a.*b, and displays the output arrays. It also contains code to plot a graph and displays the plot output.

Uploaded by

Maruf
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)
62 views

All All

The document contains the output of running multiple code snippets in MATLAB. It defines various arrays and matrices, performs operations on them like addition, multiplication and element-wise multiplication, and displays the results. For example, it defines matrices a, b, c, sets a scalar d, performs operations like a+b, a.*b, and displays the output arrays. It also contains code to plot a graph and displays the plot output.

Uploaded by

Maruf
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/ 6

Quiz2.

2 1) Assume that array c is defined as shown,and determine the contents


of the following sub-arrays

clc
clear all
close all
c=[1.1 -3.2 3.4 .6;.6 1.1 -.6 3.1;1.3 .6 5.5 .0]
c(2,:)
c(:,end)
c(1:2,2:end)
c(6)
c(4:end)
c(1:2,2:4)
c([1 3],2)
c([2 2],[3 3])

Command Window
c=

1.1000 -3.2000 3.4000 0.6000

0.6000 1.1000 -0.6000 3.1000

1.3000 0.6000 5.5000 0

ans =

0.6000 1.1000 -0.6000 3.1000

ans =

0.6000

3.1000

ans =

-3.2000 3.4000 0.6000

1.1000 -0.6000 3.1000

ans =

0.6000

ans =

-3.2000 1.1000 0.6000 3.4000 -0.6000 5.5000 0.6000 3.1000 0

ans =

-3.2000 3.4000 0.6000

1.1000 -0.6000 3.1000


ans =

-3.2000

0.6000

ans =

-0.6000 -0.6000

-0.6000 -0.6000

Quiz 2.2
3) Determine the contents of array a after the following statement are executed

Ans:
clc
clear all
close all
a=[1 2 3;4 5 6;7 8 9]
a=eye(3,3)
b=[1 2 3]
a(2,:)=b

a =
1 2 3
4 5 6
7 8 9
a =
1 0 0
0 1 0
0 0 1
b =
1 2 3
a =
1 0 0
1 2 3
0 0 1

c)
clc
clear all
close all
a=[1 2 3;4 5 6;7 8 9]
a=eye(3,3)
b=[7 8 9]
a(3,:)=b([3 1 2])
a=

1 2 3
4 5 6
7 8 9
a=

1 0 0
0 1 0
0 0 1
b=

7 8 9
a=

1 0 0
0 1 0
9 7 8
plot
clc
clear all
close all
x=0:.1:10;
y=5.*x.^2+7.*x+6;
y1=10.*x+7;
plot(x,y,'+',x,y1,'*');
title('plot of y');
xlabel('x');
ylabel('y');
grid on
clc
clear all

close all

a=[1 0;2 1]

b=[-1 2;0 1]
c=[3 0;2 0]
d=5
a+b
a+c
a.*b
a*b
a*c
a+d
a.*d
a*d

a=

1 0
2 1
b=

-1 2
0 1c =

3 0
2 0
d=

5
ans =

0 2
2 2
ans =

4 0
4 1
ans =

-1 0
0 1
ans =

-1 2
-2 5
ans =

3 0
8 0
ans =

6 5
7 6
ans =

5 0
10 5
ans =

5 0
10 5

You might also like