Unable to solve exercise using duffing equation

The first part were M1=M2=0, I can't introduce the initial values for x1(0=Vector[ 0.1:0.1:2] the code that I used is:
f=@(t,x)[x(2);x(1)-2*x(1)^3];
x1_cond=0.1:0.1:2;
x2_cond=0;
timespan=0:0.001:2;
[t,x]=ode45(f,timespan,[x1_cond;x2_cond]);
plot(t,x)
But there is a error for the initial conditions:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Please help me I am new using Matlab

 채택된 답변

darova
darova 2020년 2월 16일

0 개 추천

Where is blue part?
You should use for loop to calculate for different γ
gamma = 0.1:0.1:2;
for i = 1:length(gamma)
x1_cond=gamma(i)
% ...
end

댓글 수: 1

The blue part is cancelled because, It says that assume m1=m2=0 so I canceled the terms,

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

2020년 2월 16일

댓글:

2020년 2월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by