Cm1-Lab Assignment
Cm1-Lab Assignment
NAGERCOIL CAMPUS
AY 2024-25
LAB ASSIGNMENT
Submitted by:
5 a) Two forces, one 500 N and the other P applied by cables on each
side of the obstruction A in order to remove the spike. Write a
MATLAB program to determine:
(a) the magnitude of P necessary to such that the resultant T is
directed along the spike
(b) the magnitude of T
(c) plot P and T as a function of d. (Range of d between 1 and 20
mm).
b) The two cables MO and NO tied together at O and the loadings are
also shown. The magnitude of F is 150 N.
Known for its highly optimized matrix and vector calculations, MATLAB offers an intuitive
language for expressing problems and their solutions both mathematically and visually.
Typical uses include:
MATLAB Environment:
Matlab environment is an interactive platform, where you can write and run your Matlab
codes, and even can plot them. It allows you to do statistical calculations as well as visualize
them too. Matlab has a wide range of tools, that might be used for writing codes, plotting
graphs, and solving many complex equations
Workspace
>> x=linspace(0,pi,100);
y=2.*sin(x);
plot(x,y)
Output:
Code:
% Define the x-axis range
x = linspace(0, 2*pi, 100);
Output:
Week No. Expt. No. Experiment Name
3 a) Write a MATLAB code to plot the three functions sinx, cosx and
sinx+cosx on different axes on the same figure using the subplot
command.
Code:
% Define the x-axis range
x = linspace(0, 2*pi, 100);
% Calculate the y-values for sin(x), cos(x), and sin(x) + cos(x)
y1 = sin(x);
y2 = cos(x);
y3 = sin(x) + cos(x);
% Subplot 1: sin(x)
subplot(3,1,1);
plot(x, y1, 'b-', 'LineWidth', 2);
grid on;
xlabel('x');
ylabel('sin(x)');
title('Sine Function');
% Subplot 2: cos(x)
subplot(3,1,2);
plot(x, y2, 'r--', 'LineWidth', 2);
grid on;
xlabel('x');
ylabel('cos(x)');
title('Cosine Function');
Output:
B) Generate the MATLAB code to calculate the area and perimeter of a circle,
where the radius is entered by the user.
Code:
% Get the radius from the user
radius = input('Enter the radius of the circle: ');
Output:
Enter the radius of the circle:
12
Area of the circle: 452.39
Perimeter of the circle: 75.40
C) Write a MATLAB code to find the first order and second order derivative of the
given function f=x3-7x2+6x-61.
Code:
% Define the function
syms x
f = x^3 - 7*x^2 + 6*x - 61;
disp('Second derivative:');
disp(d2f);
Output:
First derivative:
3*x^2 - 14*x + 6
Second derivative:
6*x - 14
Output:
syms t
v = diff(x, t);
a = diff(v, t);
disp(t_zero_acc);
disp(x_zero_acc);
disp(v_zero_acc);
Output:
2/3
7/8
7/27
21/2
77/9
Code:
% Given parameters
weight = 4000; % lb
theta = 5; % degrees
v0 = 60; % mi/h
F_brake = 1500; % lb
% Convert units
g = 32.2; % ft/s^2
v0 = v0 * 5280/3600; % ft/s
a_gravity = g * sin(deg2rad(theta));
Output:
5 a) Two forces, one 500 N and the other P applied by cables on each
side of the obstruction A in order to remove the spike. Write a
MATLAB program to determine:
(a) the magnitude of P necessary to such that the resultant T is
directed along the spike
(b) the magnitude of T
(c) plot P and T as a function of d. (Range of d between 1 and 20
mm).
Code:
% Range of d
d = 1:1:20;
% Define alpha
alpha = atan(5./d);
% Define beta
beta = atan(7./d);
% Compute force P
% Define force T
ylabel('Force (N)');
grid on;
Output:
b) The two cables MO and NO tied together at O and the loadings are also shown.
The magnitude of F is 150 N.
(a) Derive the expressions relating the tension in each cable as a function of α.
(b) Write a MATLAB program to plot the tension in each cable for 0° α
90º.
(c) Determine the smallest value of α for which both cables are in tension.
Code:
Alpha = 0:2:90;
ton = abs(fon);
tom = abs(fom);
[ton_min, i] = min(ton);
[tom_min, j] = min(tom);
Ang1_min = Alpha(i);
Ang2_min = Alpha(j);
legend('fon', 'fom');
xlabel('Alpha (degree)');
grid on;
fprintf('(c)\n');
Output:
c) The position x as a function of time of a particle that moves along a straight
line is given by x (t) = 0.5t3 – 2.5t2 – 6t +15
(a) Derive expressions for the velocity and acceleration of the particle.
(b) Write a MATLAB program to plot the position, velocity and acceleration as
a function of time for 0t10 seconds.
Code:
t=1:1:10;
x = 0.5*t.^3-2.5*t.^2-6*t+15;
v=diff(x);
a=diff(v);
plot(t,x,’-o’,’MarkerIndices’,1:5:length(x))
xlabel(‘time(s)’)
ylabel(‘position(x)’)grid on;
plot(t,v,’-o’,’MarkerIndices’,1:5:length(v))
xlabel(‘time(s)’)
ylabel(‘velocity(v)’)
grid on;
Output:
A) Code:
B=[2,3];
theta=90;
R=[cosd(-theta) -sind(-theta); sind(-theta) cosd(-theta)];
C=B*R
disp('The result of the matrix rotation is:');
disp(C);
OUTPUT:
C=
-3 2
The result of the matrix rotation is:
-3 2
B)
Code:
C=[5,2,6];
theta=180;
R=[1,0,0;0 cosd(-theta) -sind(-theta); 0 sind(-theta) cosd(-theta)];C=B*R
disp('The result of the matrix rotation is:');
disp(C);
OUTPUT:
F=
526
H=
100
0 -1 0
0 0 -1
D=
5 -2 -6
the result of matrix rotation is:
5 -2 -6
C)
Code:
r=[2;3;4];
F=[5;1;-3];
M=cross(r,F);
disp('Moment of force(Torque):');
disp(M);
OUTPUT:
Moment of force(Torque):
-13
26
-13
7 A) Find the position vector and write a MATLAB code to find the
Moment of Force about point O.
Code:
r=[3,3,1.5];
F=[-6,3,10];
M=cross(r,F);
disp('the moment of force about point O is:');
disp(M);
OUTPUT:
the moment of force about point O is:
25.5000 -39.0000 27.0000
radius=5;
angular_velocity=2;
t=linspace(0,10,100);
x=radius*cos(angular_velocity*t);
y=radius*sin(angular_velocity*t);
figure;
plot(x,y);
xlabel('X(m)');
ylabel('Y(m)');title('Circular motion');
axis equal;
grid on;
OUTPUT:
Code:
r = [ 4, 5, 3];
F = [ 100, -120, 75];
M = cross(r,F);
disp('moment of force(torque) at the origin is:');disp(M);
OUTPUT:
moment of force(torque) at the origin is:
735 0 -980
Arrangement: