필터 지우기
필터 지우기

why my graph is not showing any thing ?

조회 수: 1 (최근 30일)
suketu vaidya
suketu vaidya 2020년 11월 21일
댓글: suketu vaidya 2020년 11월 21일
function Lab02
h = 0.001;
p=1;
x=0:p:0.5;
t = 0:h:0.5;
y = [0];
for i = 1:length(p)-1
k1=f(x(i),y(i));
k2=f(x(i)+1/2*h,y(i)+1/2*k1*h);
k3=f(x(i)+h,y(i)-k1*h+2*k2*h);
y(i+1)=y(i)+h/6*(1*k1+4*k2+1*k3);
end
plot(x,y);
hold on
end
%analitycal solution
function dy=f(x,y)
syms y(x);
ode=(diff(y(x),x,2))+10*y(x) +sin(100*pi*x)==0;
ySol(x) = dsolve(ode);
c1=1;
c2=1;
dy=c2*sin(3.1623*x)+c1*cos(3.1623*x)+(sin(100*pi*x))/((10000*pi*pi)-10);
end

답변 (1개)

KSSV
KSSV 2020년 11월 21일
편집: KSSV 2020년 11월 21일
Check this line:
p = 1 ;
x=0:p:0.5;
The above shpuld be repalced with proper value p. Now it will create only one value i.e. x = 0. You should repalce this line with the appropriate stpe size p.
  댓글 수: 3
KSSV
KSSV 2020년 11월 21일
Did you consider this line:
for i = 1:length(p)-1
Still your code is a mess. What exactly you are trying?
suketu vaidya
suketu vaidya 2020년 11월 21일
i want to solve ranga kutta 3rd order eqvation

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by