Solving coupled equations in Matlab
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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일
0 개 추천
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.
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일
0 개 추천
댓글 수: 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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
