how to plot the graph of the following functions?

3 次查看(过去 30 天)
*item one; y(t)=sin(5*t)*sin(50*t) for 0<=t<=3 *item two; X(t)=exp^-t(cos(2*t) + sin(2*t)) for 0<=t<=5 *item three; T(t)=int((exp^-(t-s))*sin(s),0,t) for 0<=t<=7

回答(1 个)

ag
ag 2024-9-26,6:13
Hi Munir,
To plot the graphs of the specified functions in MATLAB, we can create a script that calculates each function over its respective time range and then plots them.
The below code snippet demonstrates how to achieve this using explanatory comments:
% Define time vectors for each function
t1 = linspace(0, 3, 1000); % For y(t)
t2 = linspace(0, 5, 1000); % For X(t)
t3 = linspace(0, 7, 1000); % For T(t)
% Calculate y(t)
y = sin(5 * t1) .* sin(50 * t1);
% Calculate X(t)
X = exp(-t2) .* (cos(2 * t2) + sin(2 * t2));
% Calculate T(t) using numerical integration
T = arrayfun(@(t) integral(@(s) exp(-(t-s)) .* sin(s), 0, t), t3);
% Plot y(t)
figure;
subplot(3, 1, 1);
plot(t1, y, 'b');
title('y(t) = sin(5t) * sin(50t)');
xlabel('t');
ylabel('y(t)');
grid on;
% Plot X(t)
subplot(3, 1, 2);
plot(t2, X, 'r');
title('X(t) = e^{-t} (cos(2t) + sin(2t))');
xlabel('t');
ylabel('X(t)');
grid on;
% Plot T(t)
subplot(3, 1, 3);
plot(t3, T, 'g');
title('T(t) = int_0^t e^{-(t-s)} sin(s) ds');
xlabel('t');
ylabel('T(t)');
grid on;
For more details, please refer to the following MathWorks documentations:
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by