How to get this equation to plot

2 次查看(过去 30 天)
I am trying to plot this equation and matlab thinks it is matrix multiplication when it is not. I have included my code. I also included a screen shot of what matlab is telling me.
%x1'=10e^-3t*-sin(200t)+2e^-3t*cos(200t)
%x2'=-10e^-3t*cos(200t)+2e^-3t*sin(200t)
tspan=[-10 10];
x1=10*exp(-3*t)*(-sin(200*t))+2*exp(-3*t)*cos(200*t);
x2=-10*exp(-3*t)*cos(200*t)+2*exp(-3*t)*sin(200*t);
figure
hold on
fplot(x1,tspan,'r');
fplot(x2,tspan,'b');
xlim([0 1]);
ylim([-10 10]);
xlabel('Time');
ylabel('Solutions')
title('{x1(t)}, {x2(t)}');
grid on
hold off
  1 个评论
Torsten
Torsten 2023-9-25
You are given the derivatives x1' and x2' of x1 and x2. You need to apply MATLAB's "int" to determine their antiderivatives first before plotting.

请先登录,再进行评论。

采纳的回答

Voss
Voss 2023-9-25
Use .* for element-wise multiplication, and if you want to use fplot then x1 and x2 should be function handles (I've added "@(t)" at the beginning of their definitions to do so).
%x1'=10e^-3t*-sin(200t)+2e^-3t*cos(200t)
%x2'=-10e^-3t*cos(200t)+2e^-3t*sin(200t)
tspan=[-10 10];
x1=@(t)10*exp(-3*t).*(-sin(200*t))+2*exp(-3*t).*cos(200*t);
x2=@(t)-10*exp(-3*t).*cos(200*t)+2*exp(-3*t).*sin(200*t);
figure
hold on
fplot(x1,tspan,'r');
fplot(x2,tspan,'b');
xlim([0 1]);
ylim([-10 10]);
xlabel('Time');
ylabel('Solutions')
title('{x1(t)}, {x2(t)}');
grid on
hold off

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by