フィルターのクリア

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 Center および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by