BVP unknown parameter 2 column vector

조회 수: 5 (최근 30일)
Omer
Omer 2025년 4월 13일
댓글: Omer 2025년 4월 13일
Dear friends, Can you help me to run the code below? I tried many things but I couldn't succeed.
clear all
clc
close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global aoa_rbar aoa_r c C_L0 GJ e
% GIVEN PARAMETERS
GJ= 76.6; %Nm^2
c=0.15; %m
x_ac=0.0375; %m
x_0=0.075; %m
d=0.0; %m
L=0.6; %m
W= 11.919; %N/m
rho=1.225; %kg/m^3
aoa_r= 3*0.0174533; %rad
C_Mac=0;
C_L0=0;
C_L_aoa=4.8074; % 1/rad
N=1;
e=x_0-x_ac;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SOLUTION B.2)
q_b2=1500;
aoa_rbar=0;
solinit_b2=bvpinit(linspace(0,L,100),@guess,q_b2);
sol_b2=bvp4c(@theta_b2,@bc_b2,solinit_b2);
%% FUNC B.2 )
function dthetady_b2=theta_b2(y,theta,q_b2)
global c GJ C_L_aoa e aoa_rbar aoa_r
lamda_sq_b2=q_b2*c*C_L_aoa*e/GJ;
dthetady_b2=[theta(2) ;-lamda_sq_b2*(theta(1)+aoa_r+aoa_rbar)];
dthetady_b2=dthetady_b2(:);
end
% Initial guess function
function yinit_b2 = guess(x)
yinit_b2 = [0; 0.01];
end
function output_b2=bc_b2(theta_a,theta_b,q_b2)
output_b2=[theta_a(1) ;theta_b(2); theta_b(1)-10000];
end
  댓글 수: 1
Omer
Omer 2025년 4월 13일
Error using bvparguments
Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT,P1,P2...):
The derivative function ODEFUN should return a column vector of length 2.

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

채택된 답변

Torsten
Torsten 2025년 4월 13일
You forgot to include "C_L_aoa" as global variable in the script part of your code.
clear all
clc
close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global aoa_rbar aoa_r c C_L0 GJ e C_L_aoa
% GIVEN PARAMETERS
GJ= 76.6; %Nm^2
c=0.15; %m
x_ac=0.0375; %m
x_0=0.075; %m
d=0.0; %m
L=0.6; %m
W= 11.919; %N/m
rho=1.225; %kg/m^3
aoa_r= 3*0.0174533; %rad
C_Mac=0;
C_L0=0;
C_L_aoa=4.8074; % 1/rad
N=1;
e=x_0-x_ac;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SOLUTION B.2)
q_b2=1500;
aoa_rbar=0;
solinit_b2=bvpinit(linspace(0,L,100),@guess,q_b2);
sol_b2=bvp4c(@theta_b2,@bc_b2,solinit_b2);
plot(sol_b2.x,sol_b2.y)
grid on
%% FUNC B.2 )
function dthetady_b2=theta_b2(y,theta,q_b2)
global c GJ C_L_aoa e aoa_rbar aoa_r
lamda_sq_b2=q_b2*c*C_L_aoa*e/GJ;
dthetady_b2=[theta(2) ;-lamda_sq_b2*(theta(1)+aoa_r+aoa_rbar)];
dthetady_b2=dthetady_b2(:);
end
% Initial guess function
function yinit_b2 = guess(x)
yinit_b2 = [0; 0.01];
end
function output_b2=bc_b2(theta_a,theta_b,q_b2)
output_b2=[theta_a(1) ;theta_b(2); theta_b(1)-10000];
end
  댓글 수: 1
Omer
Omer 2025년 4월 13일
I express my gratitude to you.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by