having trouble with ode45

1 view (last 30 days)
Kelly Grissom
Kelly Grissom on 25 Nov 2015
Commented: Star Strider on 26 Nov 2015
I have a 2nd order diff eq that I am solving using using the shooting method. When I run the code I get the error Error using pin_fin>nest Too many input arguments. I have no idea why I am getting this error so any help would be greatly appreciated. Thanks.
code
function BC_at_L = pin_fin(T0)
L = 0.1; %length of the pin in meters
R = 0.005; %radius of the pin in meters
k = 250; %thermal conductivity of the pin with units of Watts per
%meter per Kelvin (W/(m*K))
epsilon = 1; %emissivity
sigma = 5.67 * 10^-8; %Stefan-Boltzmann constant with units of Watts
%per meter squared per Kelvin to the fourth
%power (W/(m^2*K^4))
Qdot = 25; %rate of heat dissipation with units of Watts
A = pi*R^2; %cross sectional area of the pin with units of meters
%squared
Qb = Qdot/A; %heat flux at the base of the pin
U0 = -Qb/k;
[dTdx] = nest;
BC_at_L = ode45(@nest,[0 L], [T0 U0]);
function [dTdx] = nest
dTdx = zeros(2,1);
dTdx(1) = (2/(k*R))*epsilon*sigma*(T0^4);
dTdx(2) = U0;
end
end

Accepted Answer

Star Strider
Star Strider on 25 Nov 2015
Your ODE function ‘nest’ has to take at least two input arguments where the first is the independent variable and the second is the variable of integration. Your ‘nest’ function takes no input arguments, and that is throwing the error. See the ode45 documentation Examples section for details. (I don’t understand your ‘nest’ function, so I can’t offer any specific solutions.)
  4 Comments
Kelly Grissom
Kelly Grissom on 26 Nov 2015
I am still getting an error message, but I do understand what was going wrong initially thanks to your answer so you did answer that question.
Star Strider
Star Strider on 26 Nov 2015
My pleasure.
What error are you getting? What ODE does ‘nest’ represent? If I understand what you’re doing (at least to some extent), we can probably get your code to work.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!