133k views
3 votes
Use MATLAB to plot these following functions:

1. y = A x cos(wt), when
a.) A = 3, w = 2 rad
8
b.) A = 2, w = 0.5 rad
c.) A = 1, w = 4 rad

User Almir
by
8.3k points

1 Answer

5 votes

Answer:

Here is the MATLAB code to plot the given functions:

% Define time values

t = linspace(0, 2*pi, 1000);

% Define constants

A1 = 3;

w1 = 2;

A2 = 2;

w2 = 0.5;

A3 = 1;

w3 = 4;

% Define functions

y1 = A1*cos(w1*t);

y2 = A2*cos(w2*t);

y3 = A3*cos(w3*t);

% Plot functions

plot(t, y1, 'r', t, y2, 'g', t, y3, 'b');

xlabel('Time');

ylabel('Amplitude');

title('Cosine Functions');

legend('A = 3, w = 2', 'A = 2, w = 0.5', 'A = 1, w = 4');

grid on;

This code will create a plot with three different cosine functions, each with different amplitudes and frequencies. The x-axis represents time, and the y-axis represents the amplitude of the function. The legend will identify which function corresponds to which color.

User Helpa
by
8.8k points