MATLAB Problem Set3
MATLAB Problem Set3
Sol
>> distance=[560,440,490,530,370]
distance =
Time =
Average velocity =
54.3689
n=
Problem 2
Create, save, and run a script file that solves the following set of equations for given values of a, b,
and c. Check your file for the case a = 112, b = 75, and c = -67.
6x - 4y + 8z = a
-5x – 3y + 7z = b
14x + 9y – 5z = c
Sol
>> alg
Enter the first coefficient 112
Enter the second coefficient 75
Enter the third coefficient -67
2.0000
-5.0000
10.0000
Problem 3
Find the roots of
x3 + 13x2 + 52x + 6 = 0
Use the poly function to confirm your answer.
Sol
r=
-6.4406 + 2.9980i
-6.4406 - 2.9980i
-0.1189
>> p=poly(r)
p=
>>
Problem 4
Confirm that
Sol
>> w=conv(u,v)
w=
.
Problem 5
Confirm that
Sol
c=
4.0000 11.0000
d=
Problem 6
Plot the polynomial
y = x3 + 13x2 + 52x + 6
over the range -7 ≤ x ≤ 1.
Sol
>> x=-7:.01:1;
>> y=x.^3+13*x.^2+52*x+6;
>> plot(x,y)
>> p=polyfit(x,y,3)
p=
>> hold on
>> plot(x,y)
>> hold on
>> xp=-7:.01:1;
>> yp=polyvali(p,xp);
80
60
40
20
0
y
-20
y
-40 yp
-60
-80
-7 -6 -5 -4 -3 -2 -1 0 1
x
Problem 7
Plot the polynomials y = 3x4 – 6x3 + 8x2 + 4x + 90 and z = 3x3 + 5x2 - 8x + 70 over the interval -3
≤ x ≤ 3. Properly label the plot and each curve. The variables y and z represent current in milliamps;
the variable x represents voltage in volts.
Sol
Problem 8
Sol
>> x=0:.05:1;
>> y=1:.2:3;
>> [X,Y]=meshgrid(x,y);
>> Z=(X-2).^2+2*X.*Y+Y.^2;
>> surf(X,Y,Z)
>> contour(X,Y,Z)