- arrayfun - https://www.mathworks.com/help/matlab/ref/arrayfun.html
- subplot - https://www.mathworks.com/help/matlab/ref/subplot.html
how to plot the graph of the following functions?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
*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
0 comentarios
Respuestas (1)
ag
el 26 de Sept. de 2024
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!
0 comentarios
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!