Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
make a bode plot from .dat file

Subject: make a bode plot from .dat file

From: Yosua Napitupulu

Date: 27 Apr, 2009 08:24:01

Message: 1 of 6

I have a data which is type .dat ,and i want to make a bode plot(magnitude plot ,phase plot and coherence plot) from the Matlab using this data (file .dat)
How can i read .dat and make a bode plot from Matlab?

Subject: make a bode plot from .dat file

From: Joerg Buchholz

Date: 27 Apr, 2009 09:26:01

Message: 2 of 6

"Yosua Napitupulu" <yosuanapitupulu@yahoo.co.id> wrote in message <gt3q31$nm9$1@fred.mathworks.com>...
> I have a data which is type .dat ,and i want to make a bode plot(magnitude plot ,phase plot and coherence plot) from the Matlab using this data (file .dat)
> How can i read .dat and make a bode plot from Matlab?

How does your data file look like? Could you give us an example of the first few lines?

Joerg

Subject: make a bode plot from .dat file

From: Yosua Napitupulu

Date: 27 Apr, 2009 10:55:03

Message: 3 of 6

"Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <gt3tn9$p73$1@fred.mathworks.com>...
> "Yosua Napitupulu" <yosuanapitupulu@yahoo.co.id> wrote in message <gt3q31$nm9$1@fred.mathworks.com>...
> > I have a data which is type .dat ,and i want to make a bode plot(magnitude plot ,phase plot and coherence plot) from the Matlab using this data (file .dat)
> > How can i read .dat and make a bode plot from Matlab?
>
> How does your data file look like? Could you give us an example of the first few lines?
>
> Joerg

This data below from the random noise with the amplitude 100( so the random value will be be between 100 till -100).Actually more than this ,I have 1000 data and even more .Because this noise output will be generated until 20 seconds.
Thank you before joerg for ur kindness

Time NoiseOutput
+0.00000000e+000 +7.21034562e+001
+1.00000000e-002 -6.33783474e+001
+2.00000000e-002 +1.59777218e+001
+3.00000000e-002 +5.18791485e+001
+4.00000000e-002 -1.31578546e+001
+5.00000000e-002 -7.13405051e+001
+6.00000000e-002 +2.77882048e+001
+7.00000000e-002 +1.40489815e+001
+8.00000000e-002 +3.94949264e+001
+9.00000000e-002 +3.08705272e+001
+1.00000000e-001 -9.19157702e+001
+1.10000000e-001 +2.95216297e+001
+1.20000000e-001 +8.22720684e+001
+1.30000000e-001 -5.06523232e+001
+1.40000000e-001 +7.68764782e+001
+1.50000000e-001 -2.95872435e+000
+1.60000000e-001 +7.08278019e+001
+1.70000000e-001 -1.81902800e+001
+1.80000000e-001 -3.14717327e+001
+1.90000000e-001 +1.42015717e+001
+2.00000000e-001 -6.41321431e+001
+2.10000000e-001 +6.93324178e+001
+2.20000000e-001 +5.23247120e+001
+2.30000000e-001 +3.30556191e+001
+2.40000000e-001 -5.66155489e+001
+2.50000000e-001 +9.48653391e+000
+2.60000000e-001 -6.56427863e+001
+2.70000000e-001 +5.83657588e+000
+2.80000000e-001 +8.21622034e+001
+2.90000000e-001 +4.71549554e+001
+3.00000000e-001 +6.64301518e+001
+3.10000000e-001 +2.24261845e+001
+3.20000000e-001 +9.25871672e+001
+3.30000000e-001 -1.91119249e+001
+3.40000000e-001 +5.28892958e+001
+3.50000000e-001 +6.07141222e+001
+3.60000000e-001 -3.42565042e+000
+3.70000000e-001 -7.44014649e+001
+3.80000000e-001 +2.04913405e+001
+3.90000000e-001 +9.34264134e+001
+4.00000000e-001 -9.22407874e+000
+4.10000000e-001 +4.88151369e+001
+4.20000000e-001 +5.84222171e+001
+4.30000000e-001 -9.87060349e+001
+4.40000000e-001 -6.73640040e+001
+4.50000000e-001 +2.80613413e+000
+4.60000000e-001 +8.61066606e+000
+4.70000000e-001 +4.40665293e+001
+4.80000000e-001 -3.28511482e+001
+4.90000000e-001 -7.41435874e+000
+5.00000000e-001 +9.40062562e+001
+5.10000000e-001 +4.07766842e+001
+5.20000000e-001 -8.50064851e+001
+5.30000000e-001 -3.64614328e+001
+5.40000000e-001 -5.04875257e+001
+5.50000000e-001 +3.43007553e+001
+5.60000000e-001 +5.91454948e+001
+5.70000000e-001 -1.89623865e+001
+5.80000000e-001 +8.70359350e+001
+5.90000000e-001 +1.14595254e+000
+6.00000000e-001 -7.60036622e+001
+6.10000000e-001 +4.51041428e+001
+6.20000000e-001 -7.03303578e+001
+6.30000000e-001 -2.26031891e+001
+6.40000000e-001 +6.28992142e+001
+6.50000000e-001 -7.05928130e+001
+6.60000000e-001 +2.47211414e+001
+6.70000000e-001 -2.89967193e+001
+6.80000000e-001 +6.66956588e+001
+6.90000000e-001 -1.57854582e+001
+7.00000000e-001 +2.99839780e+000
+7.10000000e-001 +9.47585260e-001
+7.20000000e-001 +2.73289082e+000
+7.30000000e-001 -8.24429694e+001
+7.40000000e-001 +2.76966506e+001
+7.50000000e-001 -1.49126421e+001
+7.60000000e-001 -4.57999542e+001
+7.70000000e-001 +6.92378119e+001
+7.80000000e-001 +1.68871595e+001
+7.90000000e-001 +5.05271992e+001
+8.00000000e-001 +2.74982834e+001
+8.10000000e-001 -9.42534524e+001
+8.20000000e-001 +9.00175479e+001
+8.30000000e-001 -1.21446555e+001
+8.40000000e-001 -8.61051347e+001
+8.50000000e-001 +5.67345693e+001
+8.60000000e-001 +5.69726101e+001
+8.70000000e-001 -4.36972610e+001
+8.80000000e-001 -2.99275196e+001
+8.90000000e-001 +3.87594415e+001
+9.00000000e-001 +9.85595483e+001
+9.10000000e-001 -4.14084077e+001
+9.20000000e-001 -3.72457465e+001

Subject: make a bode plot from .dat file

From: Joerg Buchholz

Date: 27 Apr, 2009 18:40:18

Message: 4 of 6

"Yosua Napitupulu" <yosuanapitupulu@yahoo.co.id> wrote in message <gt42u7$ath$1@fred.mathworks.com>...
:
:
> This data below from the random noise with the amplitude 100( so the random value will be be between 100 till -100).Actually more than this ,I have 1000 data and even more .Because this noise output will be generated until 20 seconds.
> Thank you before joerg for ur kindness
>
> Time NoiseOutput
> +0.00000000e+000 +7.21034562e+001
> +1.00000000e-002 -6.33783474e+001
> +2.00000000e-002 +1.59777218e+001
> +3.00000000e-002 +5.18791485e+001
> +4.00000000e-002 -1.31578546e+001
> +5.00000000e-002 -7.13405051e+001
> +6.00000000e-002 +2.77882048e+001
> +7.00000000e-002 +1.40489815e+001
> +8.00000000e-002 +3.94949264e+001
> +9.00000000e-002 +3.08705272e+001
> +1.00000000e-001 -9.19157702e+001
> +1.10000000e-001 +2.95216297e+001
:
:

If you saved the numerical data in the file test.dat you can load it via:

load test.dat

into the variable test. You can plot the signal over time via:

plot (test(:,1), test(:,2))

But - a Bode plot is the representation of a transfer function of a linear system - not of a time signal. You might want to plot the spectrum of the signal.

doc fft

can show you how to do that. And you might want to understand and/or explain what you mean by the Bode plot of a time signal.

Subject: make a bode plot from .dat file

From: Yosua Napitupulu

Date: 28 Apr, 2009 13:33:02

Message: 5 of 6

I have an error as following :
-------------------------error--------------
??? Index exceeds matrix dimensions.

Error in ==> estimate_angelo at 3
in = data(1:stop,2);
-----------------------error-----------------

This is the program that I made:
-----------------program---------------------
%[Txy,F] = TFESTIMATE(X, Y, WINDOW, NOVERLAP,NFFT,Fs) returns a transfer
stop =3000;
in = data(1:stop,2);
uit = data(1:stop,3);
figure(10);
[tx,fx] = tfestimate(in,uit,hanning(2^10), 2^9 , 1024, 100);
subplot(3,1,1); semilogx(fx, db(tx));
grid on;
subplot(3,1,2); semilogx(fx, angle(tx)*180/pi);
grid on;
[txycoh,wcoh] = mscohere(in, uit, hanning(2^10), 2^9, 1024, 100);
subplot(3,1,3); semilogx(wcoh, txycoh);
%axis([0.01 100 0 1]);
grid on;
Xlabel = ('Frequency Hz');
-----------program----------------------------
The data is from .dat file like below:
Time Noise Position
0.0, -71.3405050736248, -71.3282050736248, 0.0
2.0e-2, 14.0489814602884, 14.0612814602884, 0.0
4.0e-2, 30.8705271992066, 30.8828271992066, 0.0
6.0e-2, 29.5216296635386, 29.5339296635386, 0.0
8.0e-2, -50.6523231860838, -50.6400231860838, 0.0
1.0e-1, -2.95872434576944, -2.94642434576944, 0.0
1.2e-1, -18.1902800030518, -18.1779800030518, 0.0
1.4e-1, 14.2015716792554, 14.2138716792554, 0.0
1.6e-1, 69.3324177920195, 69.3447177920195, 0.0
1.8e-1, 33.0556191348135, 33.0679191348135, 0.0
2.0e-1, 9.48653391317618, 9.49883391317618, 0.0
2.2e-1, 5.83657587548638, 5.84887587548638, 0.0
2.4e-1, 47.154955367361, 47.167255367361, 0.0
2.6e-1, 22.4261844815748, 22.4384844815748, 0.0
2.8e-1, -19.1119249256123, -19.0996249256123, 0.0
3.0e-1, 60.7141222247654, 60.7264222247654, 0.0
3.2e-1, -74.4014648661021, -74.3891648661021, 0.0
3.4e-1, 93.4264133669032, 93.4387133669032, 0.0
3.6e-1, 48.8151369497215, 48.8274369497216, 0.0
3.8e-1, -98.7060349431602, -98.6937349431602, 0.0
4.0e-1, 2.80613412680246, 2.81843412680246, 0.0
4.2e-1, 44.0665293354696, 44.0788293354696, 0.0
........................................................................
........................................................................
29.5200000000018, -9.50637064164184e-1, -9.38337064164184e-1, 0.0
29.5400000000018, -61.5960936903945, -61.5837936903945, 0.0
29.5600000000018, 20.1068131532769, 20.1191131532769, 0.0
29.5800000000018, -29.3690394445716, -29.3567394445716, 0.0
29.6000000000018, 40.0015259021897, 40.0138259021897, 0.0
29.6200000000019, 95.9227893492027, 95.9350893492027, 0.0
29.6400000000019, -64.272526131075, -64.260226131075, 0.0
29.6600000000019, -9.10200656137942, -9.08970656137942, 0.0
29.6800000000019, 53.5851071946289, 53.5974071946289, 0.0
29.7000000000019, -10.8171206225681, -10.8048206225681, 0.0
29.7200000000019, 63.7628747997254, 63.7751747997254, 0.0
29.7400000000019, 31.6639963378348, 31.6762963378348, 0.0
29.7600000000019, -21.538109407187, -21.525809407187, 0.0
29.7800000000019, -12.3247119859617, -12.3124119859617, 0.0
29.8000000000019, 1.08796826123445, 1.10026826123445, 0.0
29.8200000000019, -86.2272068360418, -86.2149068360418, 0.0
29.8400000000019, -44.4876783398184, -44.4753783398184, 0.0
29.8600000000019, 99.7772182803083, 99.7895182803082, 0.0
29.8800000000019, 10.8506904707409, 10.8629904707409, 0.0
29.9000000000019, 9.736781872282, 9.749081872282, 0.0
29.9200000000019, -41.7196917677577, -41.7073917677577, 0.0
29.9400000000019, 7.41435873960479, 7.42665873960479, 0.0

Can you help why it gives an error Index exceeds matrix dimensions?

Subject: make a bode plot from .dat file

From: Yosua Napitupulu

Date: 28 Apr, 2009 13:50:17

Message: 6 of 6

first i import my data which is .dat file .After that i run the m file that i have made.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us