how to create a matlab code for runge kutta 4th order using implicit function..here i hv tried but it is showing error in line 16 as In an assignment A(I) = B, the number of elements in B and I must be the same.
이전 댓글 표시
function [ t,x] = Untitled2(h)
%UNTITLED2 Summarx of this function goes here
% Detailed etplanation goes here
t = 0:h:3;
u=t.^2;
x(1) = 0;
fx = @(t,x) 2*u;
for i=1:(length(t)-1)
k1 = fx(t(i),x(i));
k2 = fx(t(i)+0.5*h,x(i)+0.5*h*k1);
k3 = fx(t(i)+0.5*h,x(i)+0.5*h*k2);
k4 = fx(t(i)+h,x(i)+k3*h);
x(i+1) = x(i) + (1/6)*(k1+2*k2+2*k3+k4)*h;
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!