The result of g and h should not contain c
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
jixie zhuangbei
am 8 Jul. 2015
Beantwortet: Steven Lord
am 8 Jul. 2015
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151908/image.jpeg)
g and h are unknown, A curve represent the values of c
program:
x=[0 0.25 0.50 0.70 0.80 1.00 1.3];
y=[0 5 7 9 10 11 12];
a=polyfit(x,y,3);
syms X g h t
fy=vpa(poly2sym(a,X),4)%制定v为变量。函数默认x为自变量
x1=min(x):max(x);
h1=polyval(a,x1);
c=fy;
%syms g h t [g,h]=dsolve('Dg+5*g+c*h=exp(t)','Dh-g-3*h=0','g(0)=1','h(0)=0','t')
simplify(g);
simplify(h);
ezplot(g,h,[0,1.3]);axis auto
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151909/image.jpeg)
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 8 Jul. 2015
Don't pass strings into DSOLVE. If you do that, it can't substitute the value in the variable c for the c term in the string. Take a look at the examples in the documentation for DSOLVE in your installation; if you're using a sufficiently recent release, they will show you how to define symbolic functions and use those symbolic functions to define the differential equations to be solved.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Equation Solving finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!