Unexpected error
function dFdx=funode(x,F)
global Lamda
global K1
global P
dFdx=[F(2) ; -K1*P+F(1)*Lamda^2];
function res=myfunbc(Fa,Fb)
global P
res=[Fa(1) ; Fb(1)-P];
solinit=bvpinit(linspace(0,l,2),[1 0]);
sol = bvp4c(@funode,@myfunbc,solinit);
x = linspace(0,l);
F = deval(sol,x);
After that i have an error The derivative function ODEFUN should return a column vector of length 2. why?

 採用された回答

James Tursa
James Tursa 2017 年 9 月 29 日
編集済み: James Tursa 2017 年 9 月 29 日

0 投票

Make it a column vector as requested:
dFdx=[F(2) ; -K1*P+F(1)*Lamda^2];

11 件のコメント

Nadim Mhanna
Nadim Mhanna 2017 年 9 月 29 日
still the same error
James Tursa
James Tursa 2017 年 9 月 29 日
What about the other function:
res=[Fa(1) ; Fb(1)-P];
Nadim Mhanna
Nadim Mhanna 2017 年 9 月 29 日
編集済み: Nadim Mhanna 2017 年 9 月 29 日
i did corrected both but didn't work
Steven Lord
Steven Lord 2017 年 9 月 29 日
What is the size of each of the variables K1, P, and Lamda?
Nadim Mhanna
Nadim Mhanna 2017 年 9 月 29 日
編集済み: Nadim Mhanna 2017 年 9 月 29 日
They are constants i.e. k1=5 Lamda=13 P=252
Walter Roberson
Walter Roberson 2017 年 9 月 29 日
Where is the value of P coming from in your lines
function res=myfunbc(Fa,Fb)
res=[Fa(1) Fb(1)-P];
You are not using the form of "function" that would allow P to be a shared variable.
Nadim Mhanna
Nadim Mhanna 2017 年 9 月 30 日
I did it by entering global P
Nadim Mhanna
Nadim Mhanna 2017 年 9 月 30 日
For all the variables I put the global value that i did assign but still not working
Walter Roberson
Walter Roberson 2017 年 9 月 30 日
編集済み: Walter Roberson 2017 年 9 月 30 日
When you use a global variable, it is not uncommon for the global variable to turn out to be empty at the time it is used.
Nadim Mhanna
Nadim Mhanna 2017 年 9 月 30 日
okay got it Thanks all
Jan
Jan 2017 年 9 月 30 日
@Nadim Mhanna: Please do not use flags to mark a "best answer". Flagging is thought to inform admins and editors, that a contribution needs attention, because it violates the terms of use, e.g. by rudeness.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2017 年 9 月 29 日

コメント済み:

Jan
2017 年 9 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by