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

Matlab Final record

The document contains a series of MATLAB problems and solutions involving matrix operations, plotting functions, solving equations, and symbolic differentiation. It covers topics such as matrix addition, multiplication, determinants, linear algebraic equations, and graphical representations of mathematical functions. Additionally, it includes applications of MATLAB for solving differential equations, calculating forces, and analyzing friction coefficients.

Uploaded by

avinyanhce
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Matlab Final record

The document contains a series of MATLAB problems and solutions involving matrix operations, plotting functions, solving equations, and symbolic differentiation. It covers topics such as matrix addition, multiplication, determinants, linear algebraic equations, and graphical representations of mathematical functions. Additionally, it includes applications of MATLAB for solving differential equations, calculating forces, and analyzing friction coefficients.

Uploaded by

avinyanhce
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

1.

Consider the two matrices: A = [1 0 1; 2 3 4; -1 6 7] and B = [7 4 2; 3 5 6; -1 2


1] Using MATLAB, determine the following:

(a) A + B
(b) AB
(c) A2
(d) AT (e) B–1
(f ) BTAT
(g) A2 + B2 – AB
(h) determinant of A, determinant of B and determinant of AB.
Solution:
A = [1 0 1; 2 3 4; -1 6 7]
B = [7 4 2; 3 5 6; -1 2 1]
C = A + B
D = A*B
E = A^2
F=A'
H = inv(B)
J = B'*A'
K = A^2 + B^2 - A*B
det (A)
det (B)
det(A*B)

Result:
A =
1 0 1
2 3 4
-1 6 7

B =
7 4 2
3 5 6
-1 2 1

C =
8 4 3
5 8 10
-2 8 8

D =
6 6 3
19 31 26
4 40 41

E =
0 6 8
4 33 42
4 60 72

F =
1 2 -1
0 3 6
1 4 7

H =
0.1111 0.0000 -0.2222
0.1429 -0.1429 0.5714
-0.1746 0.2857 -0.3651

J =
6 19 4
6 31 40
3 26 41

K =

53 52 45
15 51 58
-2 28 42

ans =

12

ans =

-63.0000

ans =

-756.0000
2. Determine the values of x, y and z for the following set of linear algebraic equations:

Solution:

A=[0 1 -3;2 3 -1;4 5 -2]


B=[-5; 7: 10]
x=A\B

Result:

x =

-1
4
3
3.Generate an overlay plot for plotting three lines

Solution :
t = linspace(0, 2*pi, 100);
y1 = sin(t);
y2 = t;
y3 = t -(t.^3)/6 + (t.^5)/120-(t.^7)/5040;
plot(t,y1,t,y2,'-',t,y3,'o')
axis([0 5 -1 5])
xlabel('t')
ylabel('sin(t) approximation')
title('sin(t) function')
text(3.5,0, 'sin(t)')
gtext('Linear approximation')
gtext('4-term approximation')

Result:
4. Generate a plot of y(x) = e^–0.7x sin ωx where ω = 15 rad/s, and 0 ≤ x ≤ 15. Use the
colon notation to generate the x vector in increments of 0.1.

Solution :
x=[0:0.1:15];
w=15;
y=exp(-0.7*x).*sin(w*x);
plot(x,y)
title('y(x)=e^–^0^.^7^xsin\omegax')
xlabel('x')
ylabel('y')

Result:
5. Generate a plot of y(x) = e^–0.6x cos ωx where ω = 10 rad/s, and 0 ≤ x ≤ 15. Use the
colon notation to generate the x vector in increments of 0.05.

Solution :
x=[0:0.1:15];
w=10;
y=exp(-0.6*x).*cos(w*x);
plot(x,y)
title('y(x)=e^–^0^.^6^xcos\omega x')
xlabel('x')
ylabel('y')

Result :
6. Using the functions for plotting x-y data given below, plot the following functions:
(a) r2 = 5 cos 3t; 0 ≤ t ≤ 2π
(b) r2 = 5 cos 3t; 0 ≤ t ≤ 2π

Solution :
(a)

t = linspace(0,2*pi,200);
r = sqrt(abs(5*cos(3*t)));
polar(t,r)

Result:

(b)
t=linspace(0, 2*pi, 200);
r=sqrt(abs(5*cos(3*t)));
x=r.*cos(t);
y=r.*sin(t);
fill(x, y, 'k')
axis('square')
7. Solve the following set of equations using MATLAB:

Solution :
(a) A = [1 2 3 5;-2 5 7 -9; 5 7 2 -5; -1 -3 -7 7];
B = [21; 18; 25; 30];
S = A\B

Result

S =
-8.9896
14.1285
-5.4438
3.6128

Solution:

(b) A = [1 2 3 4; 2 -2 -1 1; 1 -3 4 -4; 2 2 -3 4];


B = [8;-3; 8;-2];
S =A\B

Result
S =
2
2
2
-1
8. Use diff command for symbolic differentiation of the following functions:

Solution:

>> syms x
(a) >> S1= exp (x^8);
>> diff (S1)
ans = 8*x^7*exp(x^8)

(b) >> S2=3*x^3*exp(x^5);


>> diff (S2)
ans = 9*x^2*exp(x^5) +15*x^7*exp(x^5)

(c) >> S3=5*x^3–7*x^2+3*x+6;


>> diff (S3)
ans = 15*x^2–14*x + 3

9. Use MATLAB’s symbolic commands to find the values of the following integral

Solution:

>>syms x, y, a, b >> S1= abs(x) >> int (S1, 0.2, 0.7)

ans = 9/40

10. Obtain the general solution of the following first order differential equations

Solution:

(a) >> solve (‘Dy=5*t–6*y’)

ans = 5/6*t–5/36+exp (–6*t)*C1

(b) >> dsolve (‘D2y +3*Dy + y = 0’)

ans = C1*exp (1/2*(5^ (1/2)–3)*t) + C2*exp (–1/2*(5^ (1/2) +3)*t)


11. Determine the solution of the following differential equations that satisfies the given
initial conditions.

Solution:
>> dsolve (‘Dy = –7*x^2’,‘y (1) =0.7’)
ans = –7*x^2*t + 7*x^2 + 7/10

12. Equivalent force system (addition of vectors) Three forces are applied to a bracket as
shown. Determine the total (equivalent) force applied to the bracket

Solution
F1M=400; F2M=500; F3M=700;
Th1=-20; Th2=30; Th3=143;
F1=F1M*[cosd(Th1) sind(Th1)]
F2=F2M*[cosd(Th2) sind(Th2)]
F3=F3M*[cosd(Th3) sind(Th3)]
Ftot=F1+F2+F3
FtotM=sqrt(Ftot(1)^2+Ftot(2)^2)
Th=atand(Ftot(2)/Ftot(1))

Result
F1 =
375.8770 -136.8081
F2 =
433.0127 250.0000
F3 =
-559.0449 421.2705
Ftot =
249.8449 534.4625
FtotM =
589.9768
Th =
64.9453

13. Determine the coefficient of friction in each test, and the average from all tests.

Solution
>> m=[2 4 5 10 20 50];

>> F=[12.5 23.5 30 61 117 294];

>> mu=F./(m*9.81)

Result

mu =

0.6371 0.5989 0.6116 0.6218 0.5963 0.5994

mu_ave=mean(mu)

mu_ave = 0.6109
14. Write a MATLAB program that calculates and plots the position, velocity and
acceleration of the piston for one full revolution of the crank. Assume that the crank is
rotating at a constant speed of 500rpm.Given radius of crank = 125mm and radius of crank
shaft =250mm

Solution
THDrpm=500; r=0.12; c=0.25;

THD=THDrpm*2*pi/60;

tf=2*pi/THD;

t=linspace(0,tf,200);

TH=THD*t;

d2s=c^2-r^2*sin(TH).^2;

x=r*cos(TH)+sqrt(d2s);

xd=-r*THD*sin(TH)-(r^2*THD*sin(2*TH))./(2*sqrt(d2s));

xdd=-r*THD^2*cos(TH)-(4*r^2*THD^2*cos(2*TH).*d2s+

(r^2*sin(2*TH)*THD).^2)./(4*d2s.^(3/2));

subplot(3,1,1)

plot(t,x)

grid

xlabel('Time (s)')

ylabel('Position (m)')

subplot(3,1,2)

plot(t,xd)

grid

xlabel('Time (s)')

ylabel('Velocity (m/s)')

subplot(3,1,3)

plot(t,xdd)

grid
xlabel('Time (s)')

ylabel('Acceleration (m/s^2)')

Result
15. Plot the transmissibility curve.
for i=1:6

zeta=i*0.2;

zz(i)=zeta;

for j=1:61

x(j)=(j-1)*0.1;

y(j,i)=sqrt(((1+2*zeta*x(j)).^2)/(((1-x(j).^2).^2+(2*zeta*x(j)).^2)))

end

end

for i=1:61

z1(i)=y(i,1)

z2(i)=y(i,2)

z3(i)=y(i,3)

z4(i)=y(i,4)

z5(i)=y(i,5)

z6(i)=y(i,6)

end

plot(x,z1,x,z2,x,z3,x,z4,x,z5,x,z6)

xlabel('frequency')

ylabel('Ft/ky')
16. Figure shows a weight w hung from the end of a horizontal plot of negligible weight.
The pole is attached to the wall by a pivot and id supported by a cable attached to the
wall at a higher point. The tension T, in the cable is given by

Where T= tension in the cable, W = weight of the object, Ac=length of the cable,
Ap=length of pole and d= distance along the pole at which the cable is attached. Write a
MATLAB program to (A) Determine the distance(d) at which the cable is attached to the
pole in order to minimize the tension in the cable,(B) plot the tension in the cable as a
function of d.
Solution
lc=0.40;
lp=0.50;
w=250;
d=0.05:0.05:lp;
T=w*lc*lp./(d.*sqrt(lp^2-d.^2));
plot(d*100,T,'-p');
xlabel('Distance d in cm');
ylabel('Tension in string in N');
grid on;
[Tmin,I]=min(T);
fprintf('Minimum tension is %g N at %gcm',Tmin,d(I)*100)

Minimum tension is 400.08 N at 35cm


17. Figure shows the location of the centre of gravity of a 5000 N truck for the unloaded
condition. The Location of the added load WL is at a distance of x inches behind the rear
axle. Write a MATLAB program and plot WL as a function of X for X ranging from 0to 60
mm.

Solution
x=0:0.05:60;
wl=5000./(60+x);
plot(x,wl)
xlabel('x(mm)')
ylabel('Load weight(N)')
grid on;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy