Bode Plot data extraction to xlsx file format

The coefficinets a1,a2, b1, b2 k1, k2 are computed using some arithmetic calculations according to some specific requirement. After the computation Bode plot is done for High pass, Notch and Low pass filters. The requirement for me is to obtain the data of the bode plot (corresponding magnitude vs frequency and phase vs freq) in to a csv file or text file.
Bode plot respons is as expected and the problem I am facing for the
xlswrite('data.xlsx', [dat1,dat2,dat3]) command is Input data must be a numeric, cell, or logical array.
Even in the Data Statistics tab the values are displaying as NaN
Can somebody suggest a solution or workaround ?
Code:
%HighPass Filter
Vin=[1 a1 a0];
V01=[0 ((-(k2*b2*a1))+(k2*b1)) ((-k2*b2*a0)+(k2*b0))];
LP=tf(V01,Vin)
opts = bodeoptions;
opts.FreqUnits = 'kHz';
dat1=bodeplot(LP,opts,'r');
hold on
%Notch Filter
Vin=[1,a1,a0];
V02=[b2,b1,b0];
HP=tf(V02,Vin)
opts = bodeoptions;
opts.FreqUnits = 'kHz';
dat2=bodeplot(HP,opts,'b');
hold on
%Low Pass Filter
Vin=[(K1*sqrt(a0)) (a1*(K1*sqrt(a0))) (a0*(K1*sqrt(a0)))];
V03=[0 ((b0-(b2*a0))) ((a1*b0)-(a0*b1))];
BN=tf(V03,Vin)
opts = bodeoptions;
opts.FreqUnits = 'kHz';
dat3=bodeplot(BN,opts,'g');
hold off

 Réponse acceptée

Star Strider
Star Strider le 27 Juin 2019
It is essentially impossible to get any useful results from bodeplot. It is intended to provide plot options.
Use the bode function instead:
[mag,phase,wout] = bode(sys)
mag = squeeze(mag);
phase = squeeze(phase);
You will have to transform the radian frequencies in ‘wout’ to Hz:
fHz = wout/(2*pi);

2 commentaires

Thanks a lot! Star Strider
Star Strider
Star Strider le 27 Juin 2019
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Produits

Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by