You are on page 1of 8

Ministerul Educației și Cercetării

al Republicii Moldova
Universitatea Tehnică a Moldovei
Departamentul Fizică

Raport
asupra lucării de laborator Nr.4.

la Mecanica Teoretică realizat în MATLAB


Tema: Elemente ale sistemului MATLAB

Varianta 26

A realizat st. gr. FAF-234 Roenco Maxim

A verificat dr., conf. univ. Sanduleac. I

Chișinău -2024
1
Sarcina Lucrării Nr.4

Rezolvare:

I.

% Lucrare de laborator Nr.4


% Student Roenco Maxim FAF_231
% Varianta 26
% Sarcina I
% Part 1

m = 1;
k = 1;
omega = sqrt(k/m);

t = linspace(0, 10, 1000);

x_same_direction = cos(omega * t);

x_perpendicular_directions = cos(omega * t) .* sin(omega * t);

subplot(2,1,1)
plot(t, x_same_direction, 'b')
title('Oscillations in the Same Direction')
xlabel('Time')
ylabel('Displacement')
grid on

subplot(2,1,2)
plot(t, x_perpendicular_directions, 'r')
title('Oscillations in Perpendicular Directions')
xlabel('Time')
ylabel('Displacement')
grid on

2
3
II.

t = linspace(0, 10, 1000);


omega1 = 2*pi*1;
omega2 = 2*pi*1.2;
alpha1 = 0;
alpha2 = pi/4;
A1 = 1;
A2 = 0.8;

x1 = A1 * cos(omega1 * t + alpha1);
x2 = A2 * cos(omega2 * t + alpha2);

figure;
subplot(2,2,1);
plot(t, x1, 'b', t, x2, 'r', t, x1 + x2, 'g');
title('Incoherent Harmonic Oscillations');
xlabel('Time');
ylabel('Displacement');
legend('x1', 'x2', 'x = x1 + x2');
grid on;

subplot(2,2,2);
plot(t, x1, 'b', t, x2, 'r', t, x1 + x2, 'g');
title('Coherent Harmonic Oscillations');
xlabel('Time');
ylabel('Displacement');
legend('x1', 'x2', 'x = x1 + x2');
grid on;

x3 = cos(omega1 * t) + cos(omega2 * t);


subplot(2,2,3);
plot(t, x3, 'm');
title('Incoherent Harmonic Oscillations with Beat');
xlabel('Time');
ylabel('Displacement');
grid on;

alphas = [0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi];

4
for i = 1:length(alphas)
x_combined = A1 * cos(omega1 * t + alpha1) + A2 * cos(omega2 * t +
alpha2 + alphas(i));
subplot(3,3,i);
plot(t, x_combined);
title(['\alpha = ' num2str(alphas(i))]);
xlabel('Time');
ylabel('Displacement');
grid on;

filename = ['harmonic_oscillations_alpha_' num2str(i) '.png'];


saveas(gcf, filename);
end

5
III.

alpha_values = linspace(0, pi, 9);

function lissajous_same_frequency(alpha_values)
t = linspace(0, 10, 1000);
omega = 2*pi;
A1 = 1;
A2 = 1;

figure;
for i = 1:length(alpha_values)
x = A1 * cos(omega * t + alpha_values(i));
y = A2 * cos(omega * t);
subplot(3,3,i);
plot(x, y);
title(['\alpha = ' num2str(alpha_values(i))]);
xlabel('x');
ylabel('y');
grid on;
end
end

function lissajous_different_frequency(alpha_values)
6
t = linspace(0, 10, 1000);
A1 = 1;
A2 = 1;

figure;
for i = 1:length(alpha_values)
x = A1 * cos(2*pi*t);
y = A2 * cos((2+alpha_values(i)) * pi * t);
subplot(3,3,i);
plot(x, y);
title(['\alpha = ' num2str(alpha_values(i))]);
xlabel('x');
ylabel('y');
grid on;
end
end

alpha_values = linspace(0, pi, 9);


lissajous_same_frequency(alpha_values);
lissajous_different_frequency(alpha_values);

7
Concluzii
In the framework of Laboratory Work Nr.4, we explored the functionalities of the Octave
graphics package, familiarizing ourselves with basic commands and working with m-files.
We learned to work in 2D and 3D spaces, define and use functions to calculate and display
trajectories in the plane and in space. Through this work, we gained skills in drawing graphs
in different ways and understood the importance of visualizing data in analyzing and
interpreting results. This experience will be useful in future activities related to numerical
analysis, mathematical modeling, and data visualization in fields such as engineering,
physics, and computational sciences.

You might also like