Bode Plot data extraction to xlsx file format

조회 수: 12 (최근 30일)
Karthik Nagaraj
Karthik Nagaraj 2019년 6월 27일
댓글: Star Strider 2019년 6월 27일
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

채택된 답변

Star Strider
Star Strider 2019년 6월 27일
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
Karthik Nagaraj
Karthik Nagaraj 2019년 6월 27일
Thanks a lot! Star Strider
Star Strider
Star Strider 2019년 6월 27일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by