필터 지우기
필터 지우기

Error using odearguments (line 93) BANANA must return a column vector.

조회 수: 1 (최근 30일)
Jun Jun
Jun Jun 2020년 11월 27일
댓글: Jun Jun 2020년 11월 27일
I have tried R1 = zeros(size(R1)) and R1 = zeros(R1), but it wont work. I am lost on why I keep getting Error using odearguments (line 93) BANANA must return a column vector. Thank you so much for the help!
Here is my function
function dtdz = banana(z,t)
%given conditions:
n = 1.23;
zi = 145*(10^-3);
z0 = 8.45;
u0 = 23*pi;
B0 = 0.0054;
h = 0.00734;
g = 10;
xs = 0;
xm = 0.00004386;
ps = 1937;
pm = 1.0995e+03;
c = 0.375;
T = 36;
%assume:
R1 = [10:400];
R = R1.*10^-6;
%initial conditions:
alpha = (8/9).*(((xs-xm).*B0.*R.^2)./(u0.*h.^2.*n));
beta = ((2.*R.^2)./(9.*n)).*(((ps-pm).*g-(2/h).*(((xs-xm).*B0.^2)/u0)));
dtdz = (1./(alpha.*z+beta));
end
Here is my script
t_zi = 0;
zspan = [1*(10^-3) 0.0205];
[z,t] = ode45(@banana, zspan, t_zi);
plot(z,t);
hold off
title('Radius of banana vs Time')
xlabel('Radius of banana (µm)')
ylabel('t0 (min)')

채택된 답변

Stephan
Stephan 2020년 11월 27일
You make a vector of R1 with size 1x391 in the BANANA function. Thus you have a vector of 1x391 as result - one entry for every element of R1. Since you only provide only one initial time this leads to an error. To solve for many R1 the same time use an initial vector which provides as many elements as R1 has and transpose the result in BANANA:
t_zi = zeros(391,1);
zspan = [1*(10^-3) 0.0205];
[z,t] = ode45(@banana, zspan, t_zi);
plot(z,t);
hold off
title('Radius of banana vs Time')
xlabel('Radius of banana (µm)')
ylabel('t0 (min)')
function dtdz = banana(z,~)
%given conditions:
n = 1.23;
zi = 145*(10^-3);
z0 = 8.45;
u0 = 23*pi;
B0 = 0.0054;
h = 0.00734;
g = 10;
xs = 0;
xm = 0.00004386;
ps = 1937;
pm = 1.0995e+03;
c = 0.375;
T = 36;
%assume:
R1 = 10:400;
R = R1.*10^-6;
%initial conditions:
alpha = (8/9).*(((xs-xm).*B0.*R.^2)./(u0.*h.^2.*n));
beta = ((2.*R.^2)./(9.*n)).*(((ps-pm).*g-(2/h).*(((xs-xm).*B0.^2)/u0)));
dtdz = (1./(alpha.*z+beta))';
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by