Sei sulla pagina 1di 3

Plotting and Linear Algebraic Equations

21. Use MatLab to plot the function T= 6lnt-7exp(0.2t) over the interval 1<t<3. Put title on the
plot and properly label the axes. The variable T represents temperature in degrees Celsius; the
variable t represents time in minutes.
>> t= [1:0.01:3]; T= 6*log(t)-7*exp(0.2*t);
>> plot (t,T), xlabel ('minutes'), ylabel('celcius')

22.Use Matlab to plot the function u = 2log10(60x+1) and v= 3cos(6x) over the interval 0 < x < 2.
Properly label the plot and each curve. The variables u and v represents in miles/ hour ; the
variable x represents distance in miles.
>>x= [0:0.01:2]; u= 2*log10((60*x)+1); v= 3*cos(6*x);
>>plot (x,u,x,v), xlabel ('distance in miles'), ylabel ('speed miles/hour'), gtext('u'),gtext ('v')

23.The Fourier series is a series representation of a periodic function in terms of sines and
cosines. The fourier series representation of the function
f(x) = 1 0 <x< 4/pi*(((sin(x)/1) + ((sin(3*x))/3)+((sin(5*x))/5) + ((sin(7*x))/7)))
-1 - < x < 0 is
Plot on the same graph the function f(x) and its series representation using the four terms
shown.
x= [0:0.01:pi]; y= [-pi:0.01:0]; z= 4/pi*(((sin(x)/1) + ((sin(3*x))/3)+((sin(5*x))/5) + ((sin(7*x))/7))) ;
>> z= 4/pi*(((sin(x)/1) + ((sin(3*x))/3)+((sin(5*x))/5) + ((sin(7*x))/7))) ;
>> w= 4/pi*(((sin(y)/1) + ((sin(3*y))/3)+((sin(5*y))/5) + ((sin(7*y))/7))) ;
>> plot (x,z,y,w)

24. A cycloid is the curve is the curve described by a point P on the circumference of a circular
wheel of radius r rolling along the x axis. The curved is described in parametric form by
equations.
X = r (-sin )
Y = r ( 1-cos )
>> A = [0:0.01:4*pi];
>> r = 10; x = r*(A-sin(A)); y= r*(1-cos(A))
>> plot (x,y), xlabel ('r'), ylabel ('A')

25. Use MatLab to solve the following sets of equations


7x+ 14y 6z = 95
12x 5y + 9z = -50
-5x + 7y + 15z = 145
>> A= [7,14,-6;12,-5,9;-5,7,15];
>> B= [95;-50;145];
>> solution = A\B
solution =
-3
10
4

26. It is known that the function y= ax^3 + bx^2 + cx + d passes through the following (x,y)
points: (-1,8) , (0,4) , (1,10) and (2, 68). Use the Matab left division operator / to compute the
coefficients a, b, c, and d by writing and solving four linear equations in terms of four unknowns
a, b, c, and d.

8= a(-1)^3+b(-1)^2+c(-1)+d
4= a(0)^3+b(0)^2+c(0)+d
10= a(1)^3+b(1)^2+c(1)+d
68= a(2)^3+b(2)^2+c(2)+d

>> x = [-1,1,-1,1; 0,0,0,1; 1,1,1,1; 8,4,2,1]


x=
-1 1 -1 1
0 0 0 1
1 1 1 1
8 4 2 1

>> y = [8;4;10;68]
y=
8
4
10
68
>> z = x\y
z=
7
5
-6
4

Potrebbero piacerti anche