the code is so slow , ode23, what can I do get it faster

2 views (last 30 days)
The code is so slow, how can I obtain result faster?

Accepted Answer

Torsten
Torsten on 22 Nov 2022
B1 = [0.007664184 -2.9881 0.000406092 0.1383288248 10
0.0053322412 -3.048 0.0002825517 0.0714132532 12
0.0042969663 -3.0302 0.0002159107 0.0801274422 14
0.0031679216 -3.0999 0.0001603665 0.0499956477 16
0.0024500651 3.127 0.0001253999 0.0167884315 18
0.0018020404 -3.0564 9.5879682537E-005 0.0804556617 20
0.0016002233 -3.081 8.2650745149E-005 0.0673574656 22
0.0012999792 -3.0267 6.8012139495E-005 0.1026917201 24
0.001155153 -3.0648 0.000059505 0.0825282443 26
0.0009531787 -3.0536 4.989626375E-005 0.0895396702 28
0.0008416327 -3.0188 4.3843321828E-005 0.1143555927 30
0.0007522062 -3.0274 3.8860919031E-005 0.1103797724 32
0.0006623274 -3.0246 3.4339736398E-005 0.1144002354 34
0.0005919037 -3.0258 3.0584852036E-005 0.1163171484 36
0.0005235098 -3.0065 2.7265063479E-005 0.1304833172 38
0.0004830025 -3.0225 2.4883695857E-005 0.1239731127 40
0.0004244609 -2.9805 2.2193648751E-005 0.1494148435 42
0.0004009732 -3.0266 2.0624824753E-005 0.1276295172 44
0.000359225 -2.9564 1.858626358E-005 0.1678516957 46
0.0003261346 -3.0193 1.7063118751E-005 0.1369829386 48
0.0003120171 -2.9673 1.5915213836E-005 0.1680043239 50
0.0002693305 -2.9435 0.000014329 0.1859078099 52
0.0002812117 -3.0245 1.4041725043E-005 0.1382077591 54
0.0002116965 -2.9125 1.1677432273E-005 0.2091763157 56
0.0002642234 -2.8936 1.2746849092E-005 0.2107667695 58
0.0001898308 3.1232 1.0341119994E-005 0.0932720657 60
0.00019979 -2.7536 1.0273400016E-005 0.307157976 62
0.0001991536 -3.0709 9.952607032E-006 0.119385153 64
0.000165415 -2.8053 8.73257667E-006 0.2853994795 66
0.0001700311 -3.0214 8.714461089E-006 0.1586754338 68
0.0001540148 -2.8283 7.933818969E-006 0.2734670407 70
0.0001449999 -2.966 0.000007576 0.1979668351 72
0.0001429988 -2.9023 7.277896049E-006 0.2403375186 74
0.000125105 -2.8839 6.62244223E-006 0.2469045762 76
0.0001270686 -2.9129 6.511898157E-006 0.2398268201 78
0.0001183434 -2.8587 0.000006146 0.2668548798 80
0.0001086549 -2.9165 5.704403141E-006 0.2428620316 82
0.0001095321 -2.8379 5.614745897E-006 0.2863767016 84
0.0001003129 -2.8821 5.22477478E-006 0.2646836331 86
0.0001023633 -2.8537 5.207785332E-006 0.2838450134 88
8.9119501229E-005 -2.8941 4.689761568E-006 0.2624271574 90
8.9431208625E-005 -2.825 4.629515853E-006 0.3105181392 92
8.4029056702E-005 -2.8524 4.387228996E-006 0.2875973488 94
8.2962131609E-005 -2.8202 4.252480531E-006 0.3173761643 96
7.5837905796E-005 -2.8361 3.98837164E-006 0.3048492224 98
7.86692649E-005 -2.8183 4.015409209E-006 0.3235229867 100
7.1717695792E-005 -2.8459 3.704828221E-006 0.2961609568 102
6.6648480687E-005 -2.7984 3.513714039E-006 0.3481551587 104
6.8117625807E-005 -2.8488 3.536765484E-006 0.3009997483 106
5.8206071902E-005 -2.7251 3.073588439E-006 0.386309166 108
7.1814759805E-005 -2.7222 3.550474412E-006 0.4171148351 110
6.2015859661E-005 -3.0855 3.224419127E-006 0.1183328753 112
0.000043724 -2.268 2.351290938E-006 0.751173692 114
9.4189895672E-005 -2.9131 4.459922748E-006 0.2350604009 116
8.290389035E-006 -2.7966 8.90285566E-007 0.3433514951 118
9.2249674793E-005 -2.5786 4.344121796E-006 0.5559203906 120
3.9738388966E-005 2.72 2.074549346E-006 -0.2200033243 122
5.8998789313E-005 -2.3305 2.883651306E-006 0.7267156446 124
5.1477934834E-005 -2.9539 2.600070394E-006 0.2345811745 126
4.3748274292E-005 -2.7037 2.24423694E-006 0.4291147854 128
4.2920889131E-005 -2.8276 2.253191761E-006 0.3528561867 130
3.8559644393E-005 -2.5697 2.100473049E-006 0.5150099106 132
0.000043419 -2.7568 2.203787217E-006 0.3891812655 134
4.190565899E-005 -2.5831 0.000002104 0.5052787063 136
3.952925812E-005 -2.8791 2.039152763E-006 0.3360007855 138
3.9843496416E-005 -2.6325 0.000002003 0.4888000918 140
3.2045134808E-005 -2.7572 1.7736334E-006 0.396859339 142
3.6704113016E-005 -2.629 1.866704567E-006 0.5043773117 144
3.8357601649E-005 -2.7105 1.908806335E-006 0.4409687994 146
3.0910109808E-005 -2.699 1.634479243E-006 0.4399326205 148
3.2924680129E-005 -2.6134 0.000001716 0.5120973974 150
3.0184550739E-005 -2.7275 1.601234163E-006 0.4459831001 152
3.2089824535E-005 -2.6144 1.641199384E-006 0.5008848223 154
2.7877088028E-005 -2.6825 0.000001469 0.4780345084 156
3.2197908273E-005 -2.5982 1.61960546E-006 0.5283030324 158
2.5788072583E-005 -2.7237 1.397532316E-006 0.4531567168 160
3.2284837605E-005 -2.5799 1.550766818E-006 0.5459171359 162
2.1808863907E-005 -2.7459 1.246598692E-006 0.4301531913 164
3.0628930935E-005 -2.4456 1.517077098E-006 0.6516454249 166
2.1691176273E-005 -2.7968 1.213655636E-006 0.3782103581 168
2.6578714264E-005 -2.6195 1.301771927E-006 0.6057001719 170
3.072133682E-005 -2.4603 1.489868588E-006 0.5728952952 172
1.8272751111E-005 -3.0865 1.006208225E-006 0.3058954546 174
2.2651672463E-005 -2.0312 1.215438312E-006 0.8646419989 176
4.014635778E-005 -2.7727 1.589648424E-006 0.408953742 178
6.520122655E-006 -2.5797 7.06921485E-007 0.6029304108 180
3.2481904908E-005 -2.4377 1.48463958E-006 0.637839553 182
1.3228797768E-005 -2.8968 0.000000798 0.4106349108 184
2.9657755476E-005 -2.4351 1.367795332E-006 0.685414901 186
1.2073478899E-005 -2.9184 7.97266381E-007 0.3846214058 188
2.4119593668E-005 -2.5032 1.158264615E-006 0.6463288249 190
1.8731266519E-005 -2.4323 0.000000962 0.6536899156 192
1.9884638894E-005 -2.5188 1.031606979E-006 0.6279863257 194
1.7212900952E-005 -2.6362 8.9455805E-007 0.5233562898 196
1.8455699579E-005 -2.3865 9.58618995E-007 0.7339303681 198
0.000018664 -2.6235 9.55731964E-007 0.5248793371 200
1.4636891657E-005 -2.3609 8.07481383E-007 0.7357536368 202
1.9713918482E-005 -2.6459 9.53156433E-007 0.5542332139 204
1.698542824E-005 -2.3546 8.7372002E-007 0.7426416207 206
1.5801808467E-005 -2.6642 8.27522618E-007 0.5313383428 208
1.5661160254E-005 -2.2473 7.98167358E-007 0.806384057 210
1.5538714935E-005 -2.5849 8.27332817E-007 0.6071133152 212
1.4397544326E-005 -2.4935 7.47920582E-007 0.6445859875 214
0.000017057 -2.501 0.000000836 0.6692484438 216
1.1602881072E-005 -2.2468 6.55592888E-007 0.7844653577 218
1.8474358555E-005 -2.4467 9.01869958E-007 0.6935663324 220
1.1383891732E-005 -2.6095 6.00329483E-007 0.6085541443 222
1.5753816876E-005 -2.3756 8.07438049E-007 0.7688518817 224
1.2501749107E-005 -2.7298 6.52737651E-007 0.4609734719 226
0.000013328 -1.8969 6.4438873E-007 1.0783986301 228
2.0031202311E-005 -2.6321 0.000000959 0.6351322072 230
7.434164463E-006 2.8238 0.000000423 -0.0876081536 232
2.6155788168E-005 -1.5099 1.149687243E-006 1.5067956326 234
0.000028297 2.885 1.230734851E-006 -0.1611631609 236
1.8594651733E-005 -1.036 7.97919721E-007 2.0245883201 238
0.000028714 -2.7944 1.290455603E-006 0.4081343361 240
5.781759324E-006 0.086 1.22604877E-007 2.2924759547 242
2.0303296361E-005 -2.3641 9.05487093E-007 0.7956949355 244
6.562408175E-006 -2.3678 4.20529411E-007 0.7059287778 246
1.5710055497E-005 -2.3857 7.22423213E-007 0.779339424 248
7.608412026E-006 -2.8685 4.24884228E-007 0.4972358231 250
1.3227420533E-005 -1.9391 6.36610781E-007 1.0796285422 252
5.502075479E-006 -2.4759 4.03428038E-007 0.6736835863 254
1.4832278855E-005 -2.3127 0.000000653 0.8638641066 256
0.000009448 -2.3109 4.82242059E-007 0.8066277166 258
1.180338642E-005 -2.3002 5.87770679E-007 0.8296021913 260
7.43112453E-006 -2.6061 4.09536043E-007 0.615681941 262
9.325570205E-006 -1.9936 5.02348999E-007 1.0601207339 264
1.0823665903E-005 -2.6018 5.2819906E-007 0.6222795943 266
9.656364688E-006 -2.172 0.000000472 0.9372291649 268
8.805859461E-006 -2.3985 4.54806957E-007 0.7740503526 270
6.13342145E-006 -2.0396 0.000000389 1.0133534698 272
1.2216441924E-005 -2.5762 5.47780652E-007 0.6346657284 274
5.960528776E-006 -1.6579 3.32643041E-007 1.2024667615 276
1.1091686552E-005 -2.4362 5.17658843E-007 0.7773851558 278
0.00000834 -1.7489 4.0010191E-007 1.1520900175 280
1.0438378861E-005 -2.478 5.06222158E-007 0.74706625 282
1.758843905E-006 -2.8873 1.81569793E-007 0.8570512052 284
1.6353630399E-005 -2.2829 7.19250697E-007 0.8549188529 286
1.459221766E-006 -1.474 9.6291681E-008 0.8656759059 288
1.0643940957E-005 -1.8546 5.82115167E-007 1.2408812764 290
1.2112902849E-005 -2.83 5.00833097E-007 0.345592866 292
1.753834893E-006 -1.7591 2.09433778E-007 1.3593767103 294
1.3119431306E-005 -1.5766 5.27930622E-007 1.2272426044 296
1.2307923634E-005 3.0878 4.23883417E-007 0.1954087761 298
8.78842585E-006 -0.8903 0.000000373 1.8343311991 300
1.3740395335E-005 -2.7272 5.67880363E-007 0.4898359679 302
6.887710514E-006 -0.8952 2.92685124E-007 1.8722266762 304
1.3431589531E-005 -2.5857 0.000000545 0.6706462278 306
5.710458789E-006 -1.4941 2.89400015E-007 1.2875029972 308
5.018848659E-006 -2.4952 2.90487226E-007 0.7591141636 310
4.455257909E-006 -2.1246 0.000000251 1.0687437755 312
9.706318243E-006 -2.0595 4.34869332E-007 1.0386471505 314
3.699292713E-006 -2.6639 2.14459203E-007 0.7375254892 316
8.67943599E-006 -2.0234 3.98269784E-007 1.1278085302 318
2.924299397E-006 -2.4165 2.14829747E-007 0.7621175539 320
0.00000716 -1.9088 3.35927619E-007 1.1613845336 322
4.212314575E-006 -2.5707 2.28912396E-007 0.7907972555 324
9.18566906E-006 -1.824 4.17536751E-007 1.2508310583 326
3.419900234E-006 2.6307 1.60495871E-007 0.1321368009 328
8.018871062E-006 -1.7016 3.38506039E-007 1.3530451707 330
7.081941435E-006 -2.2957 3.37803656E-007 0.9558662867 332
4.722656605E-006 -1.9306 2.42861223E-007 1.0971235187 334
4.488737848E-006 -2.4362 2.35244239E-007 0.8174573039 336
5.689609198E-006 -1.1327 2.6819541E-007 1.7115747223 338
1.2064541348E-005 -2.8936 4.66269296E-007 0.404874798 340
6.887166497E-006 -0.8228 2.5415424E-007 2.1374545798 342
7.394881116E-006 -2.5931 3.60101907E-007 0.7181101298 344
8.75387789E-007 -0.2298 6.4121702E-008 0.9749830247 346
1.1121777122E-005 -1.4762 4.3805539E-007 1.7056081494 348
8.894631845E-006 -2.8821 4.29263201E-007 0.4159642551 350
6.283099793E-006 1.0055 0.000000208 -2.3005489154 352
1.7799785341E-005 -1.8186 7.79574468E-007 1.3011761687 354
9.392865455E-006 1.8037 4.01604695E-007 -1.1856335755 356
0.000016486 -1.2487 7.10447045E-007 1.8966258261 358
1.3494150641E-005 2.7656 5.2375032E-007 -0.2458406085 360
8.351336007E-006 -0.8948 3.37462869E-007 2.065870512 362
5.539729163E-006 -2.7317 2.315833E-007 0.6026373148 364
4.451278397E-006 -1.6249 2.10170439E-007 1.4429104734 366
6.363722976E-006 -1.9255 0.000000272 1.1420744287 368
2.252051027E-006 0.6629 4.1343358E-008 2.4484718085 370
6.325909873E-006 -2.6676 2.69822239E-007 0.639841853 372
6.838703112E-006 -1.1936 2.70726408E-007 1.8016261392 374
4.83651144E-006 -2.9666 1.9538832E-007 0.5162131277 376
4.979062672E-006 -1.5176 1.97230459E-007 1.4887693573 378
3.863484298E-006 -1.3957 2.00687549E-007 1.531723542 380
3.911791321E-006 2.8706 1.50493776E-007 0.0748857973 382
6.923337622E-006 -1.5772 2.98689429E-007 1.5132497853 384
9.49065862E-007 -1.9694 7.4925983E-008 1.218950613 386
5.464949547E-006 -2.1377 2.40118949E-007 0.9724919305 388
9.52184462E-007 0.3495 4.2740823E-008 2.2537681205 390
5.152416646E-006 -1.4567 0.000000242 1.5662591999 392
5.950209074E-006 -3.1172 2.17198303E-007 0.2244800244 394
6.406053833E-006 -0.5764 2.07660203E-007 2.3164964266 396
5.128158871E-006 2.8905 1.60639235E-007 0.1968500085 398
1.1097145935E-005 -1.5137 3.89831892E-007 1.6384495586 400
4.078769645E-006 2.8555 1.84583969E-007 -0.0642371008 402
5.785767181E-006 0.0376 2.38062482E-007 2.8094212509 404
1.1984450851E-005 -2.4232 4.78846843E-007 0.6564397539 406
6.097598213E-006 0.8115 2.45694643E-007 -2.5043194333 408
7.013639537E-006 -1.4874 3.31815371E-007 1.4224320133 410
0.000003506 -3.0229 1.0889822E-007 0.0810547744 412
5.007804743E-006 1.153 6.879255E-008 -2.5191594139 414
1.2574704206E-005 -1.8316 3.99111597E-007 1.2662444202 416
1.127869296E-006 1.0188 3.4533157E-008 -3.014061121 418
1.869863792E-006 -1.4785 1.4135974E-007 1.375744977 420
3.749873819E-006 1.9782 1.17321248E-007 -1.0726557324 422
1.0551359061E-005 -1.331 3.74342765E-007 1.7822827891 424
6.633458318E-006 2.517 0.000000206 -0.3604341888 426
0.000006707 -1.1462 2.51648916E-007 2.0234067621 428
2.067602753E-006 2.5321 8.8668841E-008 -0.254796319 430
0.000001201 -0.1343 6.3710371E-008 2.0381924487 432
3.897734972E-006 -1.7923 1.54179314E-007 1.3708710291 434
7.48415348E-007 -2.0337 4.5275535E-008 1.3912065081 436
2.744615983E-006 -1.9139 1.20942413E-007 1.2212614114 438
2.624117705E-006 0.1431 8.4087737E-008 2.942845635 440
6.135401988E-006 -2.6151 0.000000234 0.5901757188 442
3.935795807E-006 -0.1999 1.60313028E-007 2.8120648586 444
3.863540495E-006 -2.398 1.73680733E-007 0.7484449575 446
2.08454968E-006 1.8483 6.1380357E-008 -1.3647109585 448
3.931825441E-006 -0.8476 1.66785219E-007 2.2057137563 450
4.225780405E-006 -2.6071 1.55429739E-007 0.5525774683 452
3.633622862E-006 -0.5307 0.000000117 2.4065539759 454
3.372449764E-006 1.7792 8.630293E-008 -1.4241322891 456
6.494593504E-006 -1.5887 2.4019241E-007 1.5221149197 458
3.474665472E-006 2.1382 1.17626052E-007 -0.9709264962 460
0.000007232 -1.0498 2.8129828E-007 2.0521377225 462
1.1818252792E-005 2.5662 3.89783207E-007 -0.4861364836 464
9.568793776E-006 0.0102 3.12271593E-007 -2.9829549922 466
1.1766667984E-005 -1.4549 4.49251152E-007 1.7525012817 468
1.4291251655E-005 2.3253 5.21693095E-007 -0.6838189242 470
1.0472060918E-005 -0.1845 4.64662377E-007 3.0480823613 472
1.371861287E-005 -2.2595 0.00000058 0.8398224636 474
1.4397354045E-005 1.0176 5.49714913E-007 -2.0623098959 476
8.786846515E-006 -1.9533 3.68596505E-007 1.3324951543 478
2.71985022E-006 2.7559 1.00123507E-007 -0.6986463378 480
4.458059261E-006 0.1599 1.25218426E-007 -2.983360104 482
9.00256221E-007 2.1841 8.051437E-009 0.0746998832 484
6.437818289E-006 -1.8849 2.21579318E-007 1.2568096554 486
6.586071395E-006 1.7864 2.33291414E-007 -1.3845408378 488
6.429549502E-006 -1.3521 2.31333354E-007 1.824521562 490
3.801872684E-006 1.8345 1.26291034E-007 -1.1256720697 492
2.877081954E-006 0.2587 1.08556401E-007 -2.9370846728 494
4.233417424E-006 -2.2972 1.53570863E-007 0.7917154803 496
3.325266172E-006 1.1931 1.22486161E-007 -1.9902205157 498
1.34388887E-007 0 4.18172E-009 3.1415926536 500];
Fx = B1(:,1);
Fx_Pi=B1(:,2);
Mx = B1(:,3);
Mx_Pi=B1(:,4);
freq=B1(:,5);
%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% Initial Conditions %%%%%%%%%%%%
IC=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% Time Span (Seconds) %%%%%%%%
t0=0; tf=5; art=0.1;
tspan=[t0:art:tf];
t_step=0.01;
ts=1/t_step;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[t,u] = ode15s(@(t,y)Huang(t,y,Fx,Fx_Pi,Mx,Mx_Pi,freq),tspan,IC); %[t,y] = ode45(@(t,y) myode(t,y,ft,f,gt,g), tspan, ic, opts);
x1 = u(:,1); x2 = u(:,2); x3 = u(:,3); x4 = u(:,4); x5 = u(:,5);
%x1 yönü thrustbearing %x5 yönü pervane
th1 = u(:,6); th2 = u(:,7); th3 = u(:,8); th4 = u(:,9); th5 = u(:,10);
%th1= yönü thrustbearing %th5= yönü pervane %detrend(y1);
figure (1),clf
plot(tspan,x1),xlabel('Frequency (Hz)'), ylabel('y (m) ');
title('Vertical Displacement (m)')
function [du] = Huang(t,u,Fx,Fx_Pi,Mx,Mx_Pi,freq)
%%%%%% Shaft Speed %%%%%%%%%%
rpm=525; %rpm
w=rpm*2*pi/60; % rad/s
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
Fx = sum(Fx(:).*sin(2*pi*freq(:)*t + Fx_Pi(:)));
Mt =sum(Mx(:).*sin(2*pi*freq(:)*t + Mx_Pi(:)));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
p=7750; %%%Kg/m^3;
g=9.81;
G=77*10^9; %%% N/m^2
E=193*10^9; %%% N/m^2
L=[0.1479 0.22034 0.3957 0.17262]; %%%m
D=[0.02 0.02 0.02 0.02]; %%m
Sh=0.02;
m(p)=0.3144;
J(p)=0.54; %0.5*10^-4;
for j=1:4
m(j)=pi*(D(j)/2)^2*L(j)*p;
A(j)=pi*D(j)^2/4 ; %%m2
J(j)=m(j)*D(j)^2/32; %%Kg*m^2
Ip(j)=pi*D(j)^4/32 ; %% m^4
dt(j)=0.05*m(j)*w;
dx(j)=0.08*J(j)*w;
kt(j)=G*Ip(j)/L(j);
kx(j)=E*A(j)/L(j);
ktx(j)=Sh*kt(j);
kxt(j)=Sh*kx(j);
end
m(1)=m(1)/2; m(2)=m(1)/2+m(2)/2; m(3)=m(2)/2+m(3)/2; m(4)=m(3)/2+m(4)/2; m(5)=m(4)/2+m(p);
J(1)=J(1)/2; J(2)=J(1)/2+J(2)/2; J(3)=J(2)/2+J(3)/2; J(4)=J(3)/2+J(4)/2; J(5)=J(4)/2+J(p);
A = [m(1) 0 0 0 0 0 0 0 0 0
0 m(2) 0 0 0 0 0 0 0 0
0 0 m(3) 0 0 0 0 0 0 0
0 0 0 m(4) 0 0 0 0 0 0
0 0 0 0 m(5) 0 0 0 0 0
0 0 0 0 0 J(1) 0 0 0 0
0 0 0 0 0 0 J(2) 0 0 0
0 0 0 0 0 0 0 J(3) 0 0
0 0 0 0 0 0 0 0 J(4) 0
0 0 0 0 0 0 0 0 0 J(5)];
D = [dx(1) -dx(1) 0 0 0 0 0 0 0 0
-dx(1) dx(1)+dx(2) -dx(2) 0 0 0 0 0 0 0
0 -dx(2) dx(2)+dx(3) -dx(3) 0 0 0 0 0 0
0 0 -dx(3) dx(3)+dx(4) -dx(4) 0 0 0 0 0
0 0 0 -dx(4) dx(4) 0 0 0 0 0
0 0 0 0 0 dt(1) -dt(1) 0 0 0
0 0 0 0 0 -dt(1) dt(1)+dt(2) -dt(2) 0 0
0 0 0 0 0 0 -dt(2) dt(2)+dt(3) -dt(3) 0
0 0 0 0 0 0 0 -dt(3) dt(3)+dt(4) -dt(4)
0 0 0 0 0 0 0 0 -dt(4) dt(4)] ;
K = [kx(1) -kx(1) 0 0 0 0 0 0 0 0
-kx(1) kx(1)+kx(2) -kx(2) 0 0 0 0 0 0 0
0 -kx(2) kx(2)+kx(3) -kx(3) 0 0 0 0 0 0
0 0 -kx(3) kx(3)+kx(4) -kx(4) 0 0 0 0 0
0 0 0 -kx(4) kx(4) 0 0 0 0 0
0 0 0 0 0 kt(1) -kt(1) 0 0 0
0 0 0 0 0 -kt(1) kt(1)+kt(2) -kt(2) 0 0
0 0 0 0 0 0 -kt(2) kt(2)+kt(3) -kt(3) 0
0 0 0 0 0 0 0 -kt(3) kt(3)+kt(4) -kt(4)
0 0 0 0 0 0 0 0 -kt(4) kt(4)] ; % K matrix
KTX = [0 0 0 0 0 kxt(1) -kxt(1) 0 0 0
0 0 0 0 0 -kxt(1) kxt(1)+kxt(2) -kxt(2) 0 0
0 0 0 0 0 0 -kxt(2) kxt(2)+kxt(3) -kxt(3) 0
0 0 0 0 0 0 0 -kxt(3) kxt(3)+kxt(4) -kxt(4)
0 0 0 0 0 0 0 0 -kxt(4) kxt(4)
ktx(1) -ktx(1) 0 0 0 0 0 0 0 0
-ktx(1) ktx(1)+ktx(2) -ktx(2) 0 0 0 0 0 0 0
0 -ktx(2) ktx(2)+ktx(3) -ktx(3) 0 0 0 0 0 0
0 0 -ktx(3) ktx(3)+ktx(4) -ktx(4) 0 0 0 0 0
0 0 0 -ktx(4) ktx(4) 0 0 0 0 0] ; % K matrix
F = [0
0
0
0
Fx
0
0
0
0
Mt];
u1 = u(1:10); % [x1 x2 x3 x4 x5 t1 t2 t3 t4 t5]
du1 = u(11:20); % [dx1 dx2 dx3 dx4 dx5 dt1 dt2 dt3 dt4 dt5]
dx1 = u(11); % dtheta
B = -D*du1 -K*u1 + KTX*u1 + F ;
du = zeros(10,1);
du(1:10) = u(11:20);
du(11:20) = A\B;
end

More Answers (0)

Categories

Find more on Modeling in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!