HELP to correct the codes of the graph of the solution of the differential equation with piecewise constant argument at Matlab

3 次查看(过去 30 天)
clc; clear; clear all;
a=1.5;
d0=1;
v0=1;
nu=sqrt(2.5);
sumxx=[];
k=250;
for p=1:k
T=linspace(0.25.*(p-1),0.25.*p,100);
sumx=d0.*cos(nu.*T)+(v0./nu).*sin(nu.*T)+((a.*d0)./nu.^2).*(1-cos(nu.*T));
for n=0:p-2
K=OMEGAm(a,n,nu,v0,d0).*(1-cos(nu.*(T-(0.25.*(n+1)))));
sumx=sumx+(a./nu.^2).*K;
end
% sumx=sumx.*x0;
sumxx=[sumxx,sumx];
clear sumx
end
tt=linspace(0,k,k*100);
plot(tt,sumxx)
xlabel('t')
ylabel('x(t)')
grid on
hold on
----------------------------------------------------------------
function w=OMEGAm(a,n,nu,v0,d0)
M=[(1-a./(nu.^2)).*cos(nu.*0.25)+a./(nu.^2) sin(nu.*0.25)./nu;-nu.*(1-a./(nu.^2)).*sin(nu.*0.25) cos(nu.*0.25)];
w=[(1-a./(nu.^2)).*cos(nu.*0.25)+a./(nu.^2)-1 sin(nu.*0.25)./nu]*(M.^n)*[d0;v0];
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by