help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Control System Design methods using Octave.


From: Doug Stewart
Subject: Re: Control System Design methods using Octave.
Date: Thu, 7 Dec 2017 15:16:47 -0500



On Thu, Dec 7, 2017 at 10:30 AM, shall689 <address@hidden> wrote:
Doug Stewart-4 wrote
> On Wed, Dec 6, 2017 at 4:57 PM, shall689 <

> sahallacy@

> > wrote:
>
>> Ok, I removed SampleFrequency from the tf function, i.e. tf(b,a) instead
>> of
>> tf(b,a,SampleFrequency).
>>
>> The bode plot seem to match each other much better and the frequency
>> range
>> is a little better, with the only issue is that the max discrete
>> frequency
>> is 10 (>> pi).
>>
>> Is there some type of issue with the bode() function?
>>
>>
>> <http://octave.1599824.n4.nabble.com/file/t372348/BodePlot2.png>
>>
>>
>>
>> --
>> Sent from: http://octave.1599824.n4.nabble.com/Octave-General-
>> f1599825.html
>>
>>
> Hi Shall
> If you would post your exact code, for me to run, then I am sure that I
> can
> answer your questions.
> https://pastebin.com/   is one way to post it.
>
>
>
> --
> DAS
>
> <https://linuxcounter.net/user/206392.html>
>
> _______________________________________________
> Help-octave mailing list

> Help-octave@

> https://lists.gnu.org/mailman/listinfo/help-octave


The a and b were reversed in the tf() function.  I corrected that issue (see
below).  Now, there is even a greater difference between the simulator's
frequency response data and the transfer function returned by invfreqz().

Stephen


pkg load control;
pkg load signal;
clear all
close all
clc
x = csvread('buckVfreqResp.csv');
SampleFrequency = 20000;
f = x(:,1);
r = x(:,2);
phase_rad = x(:,3).*(pi/180);
h = r.*cos(phase_rad) + r.*(sin(phase_rad)*i);
w = f.*2*pi/SampleFrequency;
[b,a] = invfreqz(h,w,2,2)
sys = tf(a,b,1/SampleFrequency)
bode(sys);



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave
Sorry for the long delays.

I think this is much closer to what you want.
But it is giving me complex roots and they should be closer to 2 real roots.

clear

pkg load control;
pkg load signal;
clear all
x = csvread('buckVfreqResp.csv');
SampleFrequency = 20000;
T = 1/SampleFrequency;
f = x(2:end,1);
r = x(2:end,2);
ph=x(2:end,3);
figure(1)
semilogx(f,r,f,ph)
grid minor on
# this shows that you have a total of 180 deg phase shift
#  and 90 deg is at about 515 Hrz
# so you have a second order system with a corner freq of 515 Hz.

phase_rad = ph.*(pi/180);
w=2*pi*f;
# now plot it with radians if you want to.
figure(2)
semilogx(w,r,w,phase_rad)
grid minor on

r1=10.^(r./20);
figure(3)
h = r1.*cos(ph) + r1.*(sin(ph)*i);
w = f.*(2*pi*T);


[b,a] = invfreqz(h,w,0,2)
sys = tf(b,a,T)
bode(sys)



--
DASCertificate for 206392


reply via email to

[Prev in Thread] Current Thread [Next in Thread]