Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 8.57 KB | None | 0 0
  1. %%dane
  2. f = [0:0.5:600];
  3. m1 = 70;
  4. m2 = 40;
  5. m3 = 50;
  6. m4 = 40;
  7. k1 = 3*10^6;
  8. k2 = 1*10^6;
  9. k3 = 2*10^6;
  10. k4 = 1*10^6;
  11. k5 = 0.5*10^6;
  12. h1 = 300;
  13. h2 = 100;
  14. h3 = 200;
  15. h4 = 100;
  16. h5 = 50;
  17.  
  18. %%macierze M, H, K
  19.  
  20. M=[m1,0,0,0;
  21.    0,m2,0,0;
  22.    0,0,m3,0;
  23.    0,0,0,m4];
  24.  
  25. H=[h1+h2+h4,-h2,0,-h4;
  26.    -h2,h2+h3,-h3,0;
  27.    0,-h3,h3+h5,-h5;
  28.    -h4,0,-h5,h4+h5];
  29.  
  30. K=[k1+k2+k4,-k2,0,-k4;
  31.    -k2,k2+k3,-k3,0;
  32.    0,-k3,k3+k5,-k5;
  33.    -k4,0,-k5,k4+k5];
  34.  
  35.  
  36. T = 2 *pi *f;
  37.  
  38. [n,m]=size(T);
  39. W11=[];
  40. W12=[];
  41. W13=[];
  42. W14=[];
  43. W21=[];
  44. W22=[];
  45. W23=[];
  46. W24=[];
  47. W31=[];
  48. W32=[];
  49. W33=[];
  50. W34=[];
  51. W41=[];
  52. W42=[];
  53. W43=[];
  54. W44=[];
  55.  
  56.  
  57. ; % częstość kołowa
  58.  f=[0:0.01:150];
  59.  
  60. for w =2*pi*f
  61.     W=(K-(w^2)*M+(1i)*w*H)^(-1);
  62.  
  63.     W11=[W11; W(1,1)];
  64.     W12=[W12; W(1,2)];
  65.     W13=[W13; W(1,3)];
  66.     W14=[W14; W(1,4)];
  67.     W21=[W21; W(2,1)];
  68.     W22=[W22; W(2,2)];
  69.     W23=[W23; W(2,3)];
  70.     W24=[W24; W(2,4)];
  71.     W31=[W31; W(3,1)];
  72.     W32=[W32; W(3,2)];
  73.     W33=[W33; W(3,3)];
  74.     W34=[W34; W(3,4)];
  75.     W41=[W41; W(4,1)];
  76.     W42=[W42; W(4,2)];
  77.     W43=[W43; W(4,3)];
  78.     W44=[W44; W(4,4)];
  79.  
  80. end
  81.  
  82.  
  83. mod_W11=abs(W11);
  84. mod_W12=abs(W12);
  85. mod_W13=abs(W13);
  86. mod_W14=abs(W14);
  87. mod_W21=abs(W21);
  88. mod_W22=abs(W22);
  89. mod_W23=abs(W23);
  90. mod_W24=abs(W24);
  91. mod_W31=abs(W31);
  92. mod_W32=abs(W32);
  93. mod_W33=abs(W33);
  94. mod_W34=abs(W34);
  95. mod_W41=abs(W41);
  96. mod_W42=abs(W42);
  97. mod_W43=abs(W43);
  98. mod_W44=abs(W44);
  99.  
  100. %widmo amplitudowe
  101. figure(1);
  102. subplot;
  103. plot(f,mod_W11,'b-','LineWidth',2);
  104. xlabel('f[Hz]');
  105. ylabel('W_1_1')
  106. grid
  107.  
  108. figure(1);
  109. subplot;
  110. plot(f,mod_W12,'b-','LineWidth',2);
  111. xlabel('f[Hz]');
  112. ylabel('W12')
  113. grid;
  114.  
  115. subplot;
  116. plot(f,mod_W13,'b-','LineWidth',2);
  117. xlabel('f[Hz]');
  118. ylabel('W13')
  119. grid;
  120.  
  121.  
  122. subplot;
  123. plot(f,mod_W14,'b-','LineWidth',2);
  124. xlabel('f[Hz]');
  125. ylabel('W14')
  126. grid;
  127.  
  128. figure(2);
  129. subplot;
  130. plot(f,mod_W21,'b-','LineWidth',2);
  131. xlabel('f[Hz]');
  132. ylabel('W21')
  133. grid;
  134.  
  135. subplot;
  136. plot(f,mod_W22,'b-','LineWidth',2);
  137. xlabel('f[Hz]');
  138. ylabel('W22')
  139. grid;
  140.  
  141. subplot;
  142. plot(f,mod_W23,'b-','LineWidth',2);
  143. xlabel('f[Hz]');
  144. ylabel('W23')
  145. grid;
  146.  
  147. subplot;
  148. plot(f,mod_W24,'b-','LineWidth',2);
  149. xlabel('f[Hz]');
  150. ylabel('W24')
  151. grid;
  152.  
  153. figure(3);
  154. subplot;
  155. plot(f,mod_W31,'b-','LineWidth',2);
  156. xlabel('f[Hz]');
  157. ylabel('W31')
  158. grid;
  159.  
  160. subplot;
  161. plot(f,mod_W32,'b-','LineWidth',2);
  162. xlabel('f[Hz]');
  163. ylabel('W32')
  164. grid;
  165.  
  166. subplot;
  167. plot(f,mod_W33,'b-','LineWidth',2);
  168. xlabel('f[Hz]');
  169. ylabel('W33')
  170. grid;
  171.  
  172. subplot;
  173. plot(f,mod_W34,'b-','LineWidth',2);
  174. xlabel('f[Hz]');
  175. ylabel('W34')
  176. grid;
  177.  
  178. figure(4);
  179. subplot;
  180. plot(f,mod_W41,'b-','LineWidth',2);
  181. xlabel('f[Hz]');
  182. ylabel('W41')
  183. grid;
  184.  
  185. subplot;
  186. plot(f,mod_W42,'b-','LineWidth',2);
  187. xlabel('f[Hz]');
  188. ylabel('W42')
  189. grid;
  190.  
  191. subplot;
  192. plot(f,mod_W43,'b-','LineWidth',2);
  193. xlabel('f[Hz]');
  194. ylabel('W43')
  195. grid;
  196.  
  197. subplot;
  198. plot(f,mod_W44,'b-','LineWidth',2);
  199. xlabel('f[Hz]');
  200. ylabel('W44')
  201. grid;
  202.  
  203. % fazy
  204.  
  205. faza_W11=angle(W11);
  206. faza_W12=angle(W12);
  207. faza_W13=angle(W13);
  208. faza_W14=angle(W14);
  209. faza_W21=angle(W21);
  210. faza_W22=angle(W22);
  211. faza_W23=angle(W23);
  212. faza_W24=angle(W24);
  213. faza_W31=angle(W31);
  214. faza_W32=angle(W32);
  215. faza_W33=angle(W33);
  216. faza_W34=angle(W34);
  217. faza_W41=angle(W41);
  218. faza_W42=angle(W42);
  219. faza_W43=angle(W43);
  220. faza_W44=angle(W44);
  221.  
  222. %widmo fazowe
  223.  
  224. figure(5);
  225. subplot;
  226. plot(f,faza_W11,'b-','LineWidth',2);
  227. xlabel('f[Hz]');
  228. ylabel('W_1_1');
  229. grid;
  230.  
  231.  
  232. subplot;
  233. plot(f,faza_W12,'b-','LineWidth',2);
  234. xlabel('f[Hz]');
  235. ylabel('W_1_2 ');
  236. grid;
  237.  
  238. subplot;
  239. plot(f,faza_W13,'b-','LineWidth',2);
  240. xlabel('f[Hz]');
  241. ylabel('W_1_3');
  242. grid;
  243.  
  244. subplot;
  245. plot(f,faza_W14,'b-','LineWidth',2);
  246. xlabel('f[Hz]');
  247. ylabel('W_1_4 ');
  248. grid;
  249.  
  250. figure(6);
  251. subplot;
  252. plot(f,faza_W21,'b-','LineWidth',2);
  253. xlabel('f[Hz]');
  254. ylabel('W_2_1[\circ]');
  255. grid;
  256.  
  257. subplot;
  258. plot(f,faza_W22,'b-','LineWidth',2);
  259. xlabel('f[Hz]');
  260. ylabel('W_2_2');
  261. grid;
  262.  
  263. subplot;
  264. plot(f,faza_W23,'b-','LineWidth',2);
  265. xlabel('f[Hz]');
  266. ylabel('W_2_3');
  267. grid;
  268.  
  269. subplot;
  270. plot(f,faza_W24,'b-','LineWidth',2);
  271. xlabel('f[Hz]');
  272. ylabel('W_2_4');
  273. grid;
  274.  
  275. figure(7);
  276. subplot;
  277. plot(f,faza_W31,'b-','LineWidth',2);
  278. xlabel('f[Hz]');
  279. ylabel('phi_3_1[\circ]');
  280. grid;
  281.  
  282. subplot;
  283. plot(f,faza_W32,'b-','LineWidth',2);
  284. xlabel('f[Hz]');
  285. ylabel('phi_3_2[\circ]');
  286. grid;
  287.  
  288. subplot;
  289. plot(f,faza_W33,'b-','LineWidth',2);
  290. xlabel('f[Hz]');
  291. ylabel('W_3_3');
  292. grid;
  293.  
  294. subplot;
  295. plot(f,faza_W34,'b-','LineWidth',2);
  296. xlabel('f[Hz]');
  297. ylabel('W_3_4');
  298. grid;
  299.  
  300. figure(8);
  301. subplot;
  302. plot(f,faza_W41,'b-','LineWidth',2);
  303. xlabel('f[Hz]');
  304. ylabel('phi_4_1[\circ]');
  305. grid;
  306.  
  307. subplot;
  308. plot(f,faza_W42,'b-','LineWidth',2);
  309. xlabel('f[Hz]');
  310. ylabel('phi_4_2[\circ]');
  311. grid;
  312.  
  313. subplot;
  314. plot(f,faza_W43,'b-','LineWidth',2);
  315. xlabel('f[Hz]');
  316. ylabel('phi_4_3[\circ]');
  317. grid;
  318.  
  319. subplot;
  320. plot(f,faza_W44,'b-','LineWidth',2);
  321. xlabel('f[Hz]');
  322. ylabel('W_4_4');
  323. grid;
  324.  
  325. %Częstotliwościowa funkcja przejścia
  326.  
  327. RW11=real(W11);
  328. IW11=imag(W11);
  329. RW12=real(W12);
  330. IW12=imag(W12);
  331. RW13=real(W13);
  332. IW13=imag(W13);
  333. RW14=real(W14);
  334. IW14=imag(W14);
  335. RW21=real(W21);
  336. IW21=imag(W21);
  337. RW22=real(W22);
  338. IW22=imag(W22);
  339. RW23=real(W23);
  340. IW23=imag(W23);
  341. RW24=real(W24);
  342. IW24=imag(W24);
  343. RW31=real(W31);
  344. IW31=imag(W31);
  345. RW32=real(W32);
  346. IW32=imag(W32);
  347. RW33=real(W33);
  348. IW33=imag(W33);
  349. RW34=real(W34);
  350. IW34=imag(W34);
  351. RW41=real(W41);
  352. IW41=imag(W41);
  353. RW42=real(W42);
  354. IW42=imag(W42);
  355. RW43=real(W43);
  356. IW43=imag(W43);
  357. RW44=real(W44);
  358. IW44=imag(W44);
  359.  
  360.  
  361.  
  362.  
  363. figure(9);
  364. subplot;
  365. plot(RW11,IW11,'b-','LineWidth',2);
  366. xlabel('Re(Gjw)');
  367. ylabel('IM(Gjw)');
  368. grid;
  369.  
  370. subplot;
  371. plot(RW12,IW12,'b-','LineWidth',2);
  372. xlabel('Re(Gjw)');
  373. ylabel('IM(Gjw)');
  374. grid;
  375.  
  376. subplot;
  377. plot(RW13,IW13,'b-','LineWidth',2);
  378. xlabel('Re(Gjw)');
  379. ylabel('IM(Gjw)');
  380. grid;
  381.  
  382. subplot;
  383. plot(RW14,IW14,'b-','LineWidth',2);
  384. xlabel('Re(Gjw)');
  385. ylabel('IM(Gjw)');
  386. grid;
  387.  
  388. figure(10);
  389. subplot;
  390. plot(RW21,IW21,'b-','LineWidth',2);
  391. xlabel('Re(Gjw)');
  392. ylabel('IM(Gjw)');
  393. grid;
  394.  
  395. subplot;
  396. plot(RW22,IW22,'b-','LineWidth',2);
  397. xlabel('Re(Gjw)');
  398. ylabel('IM(Gjw)');
  399. grid;
  400.  
  401. subplot;
  402. plot(RW23,IW23,'b-','LineWidth',2);
  403. xlabel('Re(Gjw)');
  404. ylabel('IM(Gjw)');
  405. grid;
  406.  
  407. subplot;
  408. plot(RW24,IW24,'b-','LineWidth',2);
  409. xlabel('Re(Gjw)');
  410. ylabel('IM(Gjw)');
  411. grid;
  412.  
  413. figure(11);
  414. subplot;
  415. plot(RW31,IW31,'b-','LineWidth',2);
  416. xlabel('Re(Gjw)');
  417. ylabel('IM(Gjw)');
  418. grid;
  419.  
  420. subplot;
  421. plot(RW32,IW32,'b-','LineWidth',2);
  422. xlabel('Re(Gjw)');
  423. ylabel('IM(Gjw)');
  424. grid;
  425.  
  426. subplot;
  427. plot(RW33,IW33,'b-','LineWidth',2);
  428. xlabel('Re(Gjw)');
  429. ylabel('IM(Gjw)');
  430. grid;
  431.  
  432. subplot;
  433. plot(RW34,IW34,'b-','LineWidth',2);
  434. xlabel('Re(Gjw)');
  435. ylabel('IM(Gjw)');
  436. grid;
  437.  
  438. figure(12);
  439. subplot;
  440. plot(RW41,IW41,'b-','LineWidth',2);
  441. xlabel('Re(Gjw)');
  442. ylabel('IM(Gjw)');
  443. grid;
  444.  
  445. subplot;
  446. plot(RW42,IW42,'b-','LineWidth',2);
  447. xlabel('Re(Gjw)');
  448. ylabel('IM(Gjw)');
  449. grid;
  450.  
  451. subplot;
  452. plot(RW43,IW43,'b-','LineWidth',2);
  453. xlabel('Re(Gjw)');
  454. ylabel('IM(Gjw)');
  455. grid;
  456.  
  457. subplot;
  458. plot(RW44,IW44,'b-','LineWidth',2);
  459. xlabel('Re(Gjw)');
  460. ylabel('IM(Gjw)');
  461. grid;
  462.  
  463. %postacie drgań
  464. A=(M^-1)*K;
  465. [U,w]=eig(A);
  466. omega=sqrt(diag(w)); % rad/s
  467. freq=omega/(2*pi); %Hz
  468.  
  469. %blok 1
  470. x1=[0,80,80,30,30,0];
  471. y1=[0,0,30,30,65,65];
  472. %blok 2
  473. x2=[0,35,35,0];
  474. y2=[0,0,30,30];
  475. %blok 3
  476. x3=[0,65,65,75,75,0];
  477. y3=[0,0,-20,-20,30,30];
  478. %blok4
  479. x4=[0,50,50,0];
  480. y4=[0,0,35,35];
  481.  
  482. %odległości bloków od osi
  483. dx1=15;
  484. dx2=60;
  485. dx3=115;
  486. dx4=115;
  487. dy1=5;
  488. dy2=40;
  489.  
  490. %położenie początku układów osi każdego bloku
  491. X1=x1+dx1;
  492. X2=x2+dx2;
  493. X3=x3+dx3;
  494. X4=x4+dx4;
  495. Y1=y1+dy1;
  496. Y2=y2+dy2;
  497. Y3=y3+dy2;
  498. Y4=y4;
  499.  
  500. %rysowanie obiektów
  501. figure(13);
  502. axis([0,200,0,80]); % wartości długości osi X i Y
  503. hold on %zatrzymaj wykres
  504. blok1=fill(X1,Y1,'m');
  505. blok2=fill(X2,Y2,'k');
  506. blok3=fill(X3,Y3,'c');
  507. blok4=fill(X4,Y4,'r');
  508.  
  509. %animacja
  510.     %parametry animacji
  511.      lbkd=10; %liczba kadr
  512.      lbpow=30; %liczba powtórzeń
  513.      wzmoc=12; %współczynnik wzmocninia
  514.      nrpost=4; %numer animowanej postaci
  515.      grid
  516. % generowanie animacji (filmu)
  517.    
  518.  k=3
  519.     X1=x1+dx1+wzmoc*U(1,nrpost)*sin((k-1)*2*pi/lbkd);
  520.     X2=x2+dx2+wzmoc*U(2,nrpost)*sin((k-1)*2*pi/lbkd);
  521.     X3=x3+dx3+wzmoc*U(3,nrpost)*sin((k-1)*2*pi/lbkd);
  522.     X4=x4+dx4+wzmoc*U(4,nrpost)*sin((k-1)*2*pi/lbkd);
  523.     set(blok1,'Xdata',X1);  
  524.     set(blok2,'Xdata',X2);
  525.     set(blok3,'Xdata',X3);
  526.     set(blok4,'Xdata',X4);
  527.     F(k)=getframe;
  528.  
  529. movie(F,lbpow);
  530.  
  531.  
  532. %zapis video
  533. %video = VideoWriter('amicacja_drgań_2.avi','Uncompressed AVI');
  534. %video.FrameRate = 15;
  535. %open(video);
  536. %writeVideo(video,F);
  537. %close(video);
  538.  
  539. %postacie drgań
  540. [U,w]==eig(inv(M)*K);
  541. w=sqrt([w(1,1);w(2,2);w(3,3);w(4,4)])/(2*pi);
  542.  
  543. kp=10000;
  544. %kv=1000;
  545. kv=2*sqrt(kp);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement