如何用matlab做这道题?求状态方程的解

2020-11-30 11:40:37 字数 6738 阅读 4227

1楼:匿名用户

题主给出微分方程组,可使用ss创建广义状态空间(gesss)模型,即将动态系统模型转换为状态空间模型形式。其模型

按照ss的方法,可以这样求解(供参考)。

a=[0,1,0;0,0,1;-2,-4,-3];

b=[1,0;0,1;-1,0];

c=[0,1,0;1,2,1];

d=[0];

x0=[1;0;0];

sys=ss(a,b,c,d);

[y,t,x] =initial(sys,x0,t);

plot(t,x,'.-',t,y,'p')运行结果

matlab状态方程解

2楼:化学工程

有关热力学的吗?还是别的?

哦!解析法是不行,那就用数值方法吧。

function odemethod

[t,x]=ode23t(@fun,0:0.1:10,[0 0 0 0])

plot(t,x)

legend('x','y','z','t'),xlabel('t')

function dx=fun(t,x)

x=x(1);y=x(2);z=x(3);w=x(4);

dx1=-0.0558*x-0.9968*y+0.0802*z+0.0415*w+0.00729;

dx2=0.598*x-0.115*y-0.0318*z-0.475+0.00775;

dx3=-0.05*x+0.388*y-0.465*z+0.296;

dx4=0.805*x+z;

dx=[dx1;dx2;dx3;dx4];

运行结果:

t =0

0.1000

0.2000

0.3000

0.4000

0.5000

0.6000

0.7000

0.8000

0.9000

1.0000

1.1000

1.2000

1.3000

1.4000

1.5000

1.6000

1.7000

1.8000

1.9000

2.0000

2.1000

2.2000

2.3000

2.4000

2.5000

2.6000

2.7000

2.8000

2.9000

3.0000

3.1000

3.2000

3.3000

3.4000

3.5000

3.6000

3.7000

3.8000

3.9000

4.0000

4.1000

4.2000

4.3000

4.4000

4.5000

4.6000

4.7000

4.8000

4.9000

5.0000

5.1000

5.2000

5.3000

5.4000

5.5000

5.6000

5.7000

5.8000

5.9000

6.0000

6.1000

6.2000

6.3000

6.4000

6.5000

6.6000

6.7000

6.8000

6.9000

7.0000

7.1000

7.2000

7.3000

7.4000

7.5000

7.6000

7.7000

7.8000

7.9000

8.0000

8.1000

8.2000

8.3000

8.4000

8.5000

8.6000

8.7000

8.8000

8.9000

9.0000

9.1000

9.2000

9.3000

9.4000

9.5000

9.6000

9.7000

9.8000

9.9000

10.0000

x =0 0 0 0

0.0032 -0.0464 0.0280 0.0015

0.0111 -0.0921 0.0530 0.0061

0.0237 -0.1367 0.0751 0.0139

0.0408 -0.1799 0.0945 0.0250

0.0622 -0.2216 0.1112 0.0394

0.0877 -0.2614 0.1256 0.0573

0.1172 -0.2992 0.1377 0.0787

0.1502 -0.3347 0.1477 0.1038

0.1868 -0.3678 0.1558 0.1325

0.2264 -0.3983 0.1621 0.1650

0.2689 -0.4260 0.1668 0.2014

0.3139 -0.4508 0.1701 0.2417

0.3612 -0.4725 0.1722 0.2860

0.4104 -0.4912 0.1732 0.3344

0.4613 -0.5066 0.1732 0.3868

0.5135 -0.5189 0.1724 0.4433

0.5667 -0.5278 0.1711 0.5039

0.6206 -0.5335 0.1692 0.5687

0.6748 -0.5359 0.1670 0.6377

0.7291 -0.5350 0.1646 0.7108

0.7831 -0.5309 0.1622 0.7880

0.8366 -0.5237 0.1598 0.8693

0.8892 -0.5133 0.1576 0.9546

0.9407 -0.5000 0.1557 1.0439

0.9908 -0.4838 0.1542 1.1371

1.0393 -0.4649 0.1532 1.2342

1.0859 -0.4434 0.1527 1.3350

1.1304 -0.4194 0.1530 1.4395

1.1726 -0.3931 0.1539 1.5475

1.2123 -0.3647 0.1557 1.6589

1.2493 -0.3344 0.1583 1.7737

1.2836 -0.3022 0.1618 1.8916

1.3149 -0.2685 0.1662 2.0126

1.3432 -0.2335 0.1715 2.1364

1.3683 -0.1973 0.1779 2.2630

1.3903 -0.1601 0.1852 2.3922

1.4090 -0.1221 0.1935 2.5237

1.4244 -0.0836 0.2028 2.6576

1.4365 -0.0447 0.2131 2.7935

1.4453 -0.0057 0.2244 2.9314

1.4509 0.0333 0.2365 3.0710

1.4533 0.0720 0.2496 3.2122

1.4525 0.1103 0.2636 3.3548

1.4487 0.1480 0.2783 3.4987

1.4419 0.1848 0.2938 3.6436

1.4322 0.2207 0.3101 3.7895

1.4199 0.2555 0.3270 3.9361

1.4049 0.2890 0.3444 4.0833

1.3876 0.3211 0.3625 4.2310

1.3680 0.3517 0.3809 4.3791

1.3463 0.3807 0.3998 4.5273

1.3227 0.4079 0.4189 4.6757

1.2974 0.4333 0.4383 4.8239

1.2706 0.4568 0.4579 4.9721

1.2425 0.4783 0.4776 5.1200

1.2133 0.4978 0.4973 5.2676

1.1832 0.5153 0.5170 5.4147

1.1525 0.5307 0.5364 5.5613

1.1211 0.5441 0.5558 5.7074

1.0895 0.5553 0.5749 5.8529

1.0579 0.5645 0.5936 5.9977

1.0263 0.5717 0.6120 6.1419

0.9951 0.5769 0.6299 6.2853

0.9643 0.5801 0.6473 6.4280

0.9342 0.5814 0.6642 6.5700

0.9049 0.5809 0.6804 6.7113

0.8767 0.5787 0.6960 6.8518

0.8495 0.5747 0.7110 6.9917

0.8237 0.5693 0.7252 7.1308

0.7994 0.5623 0.7386 7.2694

0.7766 0.5540 0.7513 7.4074

0.7554 0.5444 0.7631 7.5448

0.7361 0.5338 0.7742 7.6817

0.7186 0.5220 0.7844 7.8182

0.7031 0.5095 0.7937 7.9544

0.6895 0.4962 0.8023 8.0903

0.6780 0.4822 0.8099 8.2260

0.6686 0.4678 0.8168 8.3616

0.6613 0.4531 0.8228 8.4972

0.6561 0.4380 0.8280 8.6328

0.6530 0.4229 0.8325 8.7686

0.6520 0.4079 0.8362 8.9047

0.6531 0.3930 0.8391 9.0410

0.6563 0.3784 0.8413 9.1778

0.6614 0.3642 0.8429 9.3151

0.6685 0.3504 0.8438 9.4529

0.6774 0.3374 0.8442 9.5916

0.6882 0.3250 0.8440 9.7310

0.7006 0.3135 0.8433 9.8713

0.7147 0.3029 0.8422 10.0126

0.7302 0.2933 0.8406 10.1549

0.7471 0.2848 0.8387 10.2983

0.7653 0.2774 0.8365 10.4430

0.7847 0.2712 0.8341 10.5889

0.8050 0.2663 0.8314 10.7362

0.8263 0.2627 0.8286 10.8849

0.8484 0.2604 0.8257 11.0351

0.8711 0.2595 0.8228 11.1867

0.8942 0.2600 0.8199 11.3399

0.9178 0.2618 0.8171 11.4947