- Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
- Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
- Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support using the telephone icon in the upper-right corner of this page so we can investigate.
solution with the Runge-Kutta method HELPP
1 次查看(过去 30 天)
显示 更早的评论
for i=1:(length(x)-1) % calculation loop
k_1 = F_xy(x(i),y(i));
k_2 = F_xy(x(i)+0.5*h,y(i)+0.5*h*k_1);
k_3 = F_xy((x(i)+0.5*h),(y(i)+0.5*h*k_2));
k_4 = F_xy((x(i)+h),(y(i)+k_3*h));
y(i+1) = y(i) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h; % main equation
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/321919/image.png)
Employ the Classical RK-4 method to integrate the given equations from x=0 to x=1 using at least one single step with the initial conditions, y(0)=2 and z(0)=4.
1 个评论
Steven Lord
2020-6-25
What help do you need?
回答(1 个)
James Tursa
2020-6-25
This is clearly a homework/exam question, so I will only offer hints. The code you have posted is for a single scalar differential equation. But you have two of these equations. You can either duplicate the stuff inside the loop for the z equation, or you can turn the code into a vector form that can handle any number of equations. I prefer the second approach because it is less code to write, and once you have written it, it will work for any number of equations. But either approach can work.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!