Filter löschen
Filter löschen

Error in solving second order diff eq. Error in odearguments

2 Ansichten (letzte 30 Tage)
Ketav Majumdar
Ketav Majumdar am 29 Nov. 2016
Kommentiert: Star Strider am 30 Nov. 2016
Hi, I am trying to solve a second order differential equation using ode15s and ode45. The are my scripts and driver files:
Script
% code
%Mechanical Properties of Material
E=200e9;
nu=0.3;
%Constants A,B,C,D in the Equations
a11= (1/E);
a12= (-nu/E);
a33= (1/E);
A= (a12)/(a11+a12);
B= ((a33)-((2*a12^2)/(a11+a12)));
C= (a11)/(a11.^2-a12.^2);
D= (2*a12+a11)/(a11+a12);
%Finding Sigma_rr
O =(D+B*C-A*D);
M = A-2;
function Sigma_rr = Euler_Cauchy(t,y)
Sigma_rr = [y(2); (1/t)*(M*y(2)+O*y)];
end
and
driver file
% tspan = [1 1.2];
y0 = [100000000, 0];
[t,y] = ode15s(@Sigma_rr, tspan, y0);
plot(t,y(:,1))
figure
plot(t,y(:,2))
end
I get the following error message
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in IsotropicThickWallCylinderPlot (line 3)
[t,y] = ode15s(@Sigma_rr, tspan, y0);
I have been on the forums here but have had no luck in figuring out whats wrong. I have terrible matlab skills so any help will be much appreciated.

Antworten (1)

Star Strider
Star Strider am 29 Nov. 2016
You have two errors:
  1. Your function is ‘Euler_Cauchy’, not ‘Sigma_rr’, and since ‘Sigma_rr’ variable is local only to the function, so it doesn’t exist in your workspace;
  2. The ‘y’ argument is a (2x1) vector so you need to substitute ‘y(1)’ for ‘y’ in the second row in your ODE function matrix (since I assume that is what you intended).
This works:
%Constants A,B,C,D in the Equations
a11= (1/E);
a12= (-nu/E);
a33= (1/E);
A= (a12)/(a11+a12);
B= ((a33)-((2*a12^2)/(a11+a12)));
C= (a11)/(a11.^2-a12.^2);
D= (2*a12+a11)/(a11+a12);
%Finding Sigma_rr
O =(D+B*C-A*D);
M = A-2;
Euler_Cauchy = @(t,y) [y(2); (1/t)*(M*y(2)+O*y(1))];
tspan = [1 1.2];
y0 = [100000000, 0];
[t,y] = ode15s(Euler_Cauchy, tspan, y0);
plot(t,y(:,1))
figure
plot(t,y(:,2))
  2 Kommentare
Ketav Majumdar
Ketav Majumdar am 30 Nov. 2016
ok that solved the issue! thank you very much. However, i believe there has been an error in the way the boundary conditions have been specified.
The boundary conditions given are:
y(1)=-100E6; y(1.2)=0;
Ive looked around however the matlab documents only give a case where the boundary conditions are for y and y'. Any suggestions?
Star Strider
Star Strider am 30 Nov. 2016
My pleasure.
The ode15s solver is for stiff initial-value problems. For boundary value problems, you need bvp4c or bvp5c. I have limited experience with them (and none recent), so I can’t suggest code for a specific solution.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by