Pages

Subscribe:

Tuesday, April 28, 2015

Matlab: How To Plot Data Array to Bode Diagram

There is numorous research that need us to plot Bode Diagram, using the usual way, we can plot bode diagram easily using matlab command bode(sys). where sys is transfer function.
Unfortunately, we didnt know  the transfer function of our system, maybe because of nonlinearity or system is too complex to convert to transfer function.

What we have is only the data, then we can convert the data to bode diagram. Lets see the following example

data=[10   0.0911222683470981   -1.58847081420007
17.1132830416178   0.155513705289354   -1.59826007442724
29.2864456462524   0.265372788697364   -1.61337362876168
50.1187233627272   0.452875507309409   -1.63924925736688
85.7695898590894   0.771380837522393   -1.6844579215245
146.779926762207   1.30422486175599   -1.76177744417405
251.188643150958   2.15885228954428   -1.88922949657677
429.866234708228   3.38909945622017   -2.08389456518048
735.642254459642   4.79331476991719   -2.33778424860481
1258.92541179417   5.90723048305756   -2.59657088827632
2154.43469003188   6.51210885390879   -2.80121801151038
3686.94506451958   6.76551329794937   -2.93773717631133
6309.57344480193   6.85906013908311   -3.02175637289138
10797.7516232771   6.89190068991012   -3.07200435455205
18478.4979742229   6.9032185997441    -3.10201666772075
31622.7766016838   6.90708374137897   -3.12039586346281
54116.9526546464   6.90836924161824   -3.13252146311361
92611.8728128794   6.90870360455884   -3.14196763982071
158489.319246112   6.90851104747202   -3.15152485034634
271227.257933203   6.90754724630841   -3.16401689981387
464158.883361278   6.90459064111762   -3.18312952818843
794328.234724283   6.8959080205459   -3.21447528466877
1359356.39087853   6.87065827244468   -3.26713087846712
2326305.06715363   6.79832956499895   -3.35572740118132
3981071.70553497   6.59941778875662   -3.50204977064032
6812920.69057961   6.10718328006143   -3.73075734041662
11659144.0117983   5.13927320828323   -4.04839453004176
19952623.1496888   3.82351328567971   -4.42101649285181
34145488.738336    2.62807468084941   -4.80832034047117
58434141.3373518   1.83567026586748   -5.20125372342626
99999999.9999999   1.41059927338957   -5.58031981846252]





To Convert To Bode diagram, use the following Matlab script

f=log10(data(:,1));
gain=20*log(data(:,2));phase=data(:,3);
close;subplot(2,1,1);plot(f,gain);
xlabel('frequency log10(\omega)');ylabel('Gain(dB)');title('Amplitude')
subplot(2,1,2);plot(f,phase);
xlabel('frequency log10(\omega)');ylabel('Phase(rd)');title('Phase')


 

No comments:

Post a Comment