编程知识 cdmana.com

关于Matlab微分方程求解问题

img


求该题答案,自己写的代码老是报错。希望可以有人能指点指点,万分感谢




参考答案1:

你好!
数值解:

% y(1)对应y;y(2)对应zf = @(x,y)  [sin(x)+y(2); 1+x-y(1)];[x,y] = ode45(f, [0,10], [2;7]);plot(x,y); legend('y','z')

img

解析解:

syms y(x) z(x) xeq = [diff(y,1)-sin(x)==z, diff(z,1)+y==1+x];conds = [y(0)==2, z(0)==7];s = dsolve(eq,conds);z = matlabFunction(s.z);y = matlabFunction(s.y);fplot(y, [0,10], 'r--'); hold onfplot(z, [0,10], 'b-');legend('y','z')

img

有帮助望采纳哟




参考答案2:



参考答案3:

解析

syms y z x;[y z]=dsolve('Dy-z=sin(x)','Dz+y=1+x','y(0)=2','z(0)=7','x');vpa(y)vpa(z)

数值

% y 是y(1)  z是y(2)f = @(x,y)[sin(x)+y(2);1-x-y(1)];[x,y]=ode45(f,[0,200],[2;7]);plot(x,y(:,1));hold on;plot(x,y(:,2));grid on;

img




参考答案4:

版权声明
本文为[CSDN问答]所创,转载请带上原文链接,感谢
https://ask.csdn.net/questions/7540513

Scroll to Top