Solving coupled equations in Matlab
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hii Friend,
I have set of coupled differential equations which i need to solve and plot using matlab.
I am confused on how to proceed.Do suggest me on how to proceed with it.
The final out needed is a plot of abs(B(1)) Versus delk versus Z as shown in the pic.
採用された回答
Star Strider
2015 年 1 月 29 日
First, follow the documentation and write your ODE function, then use the appropriate ODE solver (try ode45 first) to integrate it. If you have problems, describe them, completely copying and pasting any error messages that occur, and attach your script and your ODE function files. We will do our best to help you get your code running if you need our help.
16 件のコメント
Pavan Kumar
2015 年 1 月 29 日
編集済み: Pavan Kumar
2015 年 2 月 3 日
Thanks for the suggestion star Strider.
I have written the code for both the function and function calling part.The initial conditions for B1,B2 and B3 are 0.1,0 and 1 respectively. i need to pass delk variable in the ode45 and then make the 3d plot as shown above.I am stuck here.
Star Strider
2015 年 1 月 29 日
編集済み: Star Strider
2015 年 1 月 29 日
My pleasure.
You would pass extra parameters, such as ‘delk’ to your ‘DB’ function as:
function dB = DFG789(Z1,B,delk)
...
then in your ode45 call, define ‘delk’ in your workspace and call your function as:
delk = ...
[Z1,B] = ode45(@(Z1,B) DFG789(ZI,B,delk),[0 5],[(0.1) 0 1]);
For your 3D plot, I would use the plot3 function.
You don’t report any problems in integrating your function otherwise, so I assume all is going well.
Pavan Kumar
2015 年 1 月 29 日
編集済み: Pavan Kumar
2015 年 2 月 3 日
Made the recommended changes but still landing up in few errors.
Star Strider
2015 年 1 月 29 日
You need to be certain that the ‘dB(1)’ assignment returns only a single scalar value, not a vector. At least ‘R’ is a vector because ‘Ls’ is a vector (and so are all other variables that are functions of ‘Ls’). They cannot be, and still work in your ‘DFG789’ function. The output of your ‘DFG789’ function has to be a (3x1) column vector, ‘dB’.
Pavan Kumar
2015 年 1 月 29 日
I am not knowing how t0 rectify the mistake, any suggestion on how to proceed with it?
Star Strider
2015 年 1 月 29 日
I am sorry, but I do not understand what you are doing. I can help with the MATLAB code if you have syntax or logic problems, but not in your writing your ‘DFG789’ function.
Pavan Kumar
2015 年 1 月 29 日
I have got the right results using while delk=0 value with the same set of equations. But varying delk is causing the problem. i guess the equations are right,only the definition of delk is changed here.That's my confusion.
Star Strider
2015 年 1 月 29 日
Your ‘delk’ variable needs to be a scalar. That is why it works as zero. It is a vector because it is otherwise a function of ‘Ls’, and it cannot be a vector for it to work in your ‘DFG789’ function.
Pavan Kumar
2015 年 1 月 29 日
Ok...In my case,it is definitely a vector so i need to alter something.Will slog it out..Thanks a lot bro..Will get back to you once i get the solution
Star Strider
2015 年 1 月 29 日
If ‘delk’ varies with ‘Z1’ or some other external variable, perhaps you can use that relationship to define it as a scalar for each iteration. Just a guess on my part.
Pavan Kumar
2015 年 1 月 29 日
Is it possible to use ode45 for two variables like in this case B(1) is a function of delk and Z? If not,is there any other alternative?
Pavan Kumar
2015 年 2 月 3 日
Hii Bro,
I got the solution to the problem,Thanks a lot for the advise.
Pavan
Star Strider
2015 年 2 月 3 日
My pleasure.
I would be interested in knowing how you solved the problem. I do not have sufficient understanding of the process you are modeling in your ODE to suggest a solution.
Pavan Kumar
2015 年 2 月 9 日
編集済み: Star Strider
2015 年 2 月 9 日
Hii..Sorry for the belated reply.
I followed the following way
Delk=[1:20];
for i=1:20
delk=Delk(i)
[Z1,B] = ode45(@(t,x)DFG789(t,x,delk),[0 3],[(0.1) 0 1]);
Z1_complete(i,:,:)=Z1(:,:);
end
:)
Star Strider
2015 年 2 月 9 日
No worries!
Thank you for following up.
I was curious as to how you incorporated the vector into your ODE function, as much to satisfy my curiosity as to help anyone else who searches for your Question with the same problem.
Muhammad Muti ur rehman
2021 年 8 月 4 日
Hi strider I am usig bvp4c to solve coupled or non linear equation like velocity concentration temperature.. When i have to plot on velocity profile. I use the command plot (x1, y1(2, :)) for concentration 4 and temperature 6. If i have another linear equation like density of motile microorganism what number i should put.. To get the desired graph??
その他の回答 (1 件)
Taimur Zaman
2018 年 10 月 5 日
編集済み: Walter Roberson
2021 年 10 月 6 日
1 件のコメント
Walter Roberson
2021 年 10 月 16 日
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
