Академический Документы
Профессиональный Документы
Культура Документы
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=
ans =
ans =
0.6000
3.1000
ans =
ans =
0.6000
ans =
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