Answers: y 1.0000:1.5000:2.0000:3.0000 Z 5:4:3:2 Linspace (4,8,3) Linspace (3,-15,5)
Answers: y 1.0000:1.5000:2.0000:3.0000 Z 5:4:3:2 Linspace (4,8,3) Linspace (3,-15,5)
CS10-8L/A3
CS10-8L: Computer Programming Laboratory
Exercise #2: Variables, Scripts and Visualizations
ANSWERS
1.
Result:
X=1
Y=1
Z=-2
Commands:
A=[-2 1 -6; -4 -1 -3; 8 -1 4];
B=[11; 1; -1];
ANS= A\B
ANS =
1
1
-2
2. Commands:
a. x= 3:4:5:6
b. y= 1.0000:1.5000:2.0000:3.0000
c. z= 5:4:3:2
d. linspace(4,8,3)
e. linspace(3,-15,5)
3.
Function name: sind – Sine of argument in degrees.
Commands:
sind(90)
ans =
4.
a. weight.m
Weight in kilos: 75kg
Script:
pounds=165;
kilos=pounds/2.2
kilos =
75
b. resistance.m
Combined resistance: 1.2766
Script:
r1=3;
r2=4;
r3=5;
rt=1/(1/r1 + 1/r2 + 1/r3)
rt =
1.2766
c. vertorcoordinates.m
x: 1.4077
y: 1.4207
Script:
r=2;
theta = 0.79;
x = r * cos(theta)
x =
1.4077
y = r * sin(theta)
y =
1.4207