[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Forming Cell of systems
From: |
Thomas D. Dean |
Subject: |
Re: Forming Cell of systems |
Date: |
Sat, 13 Jun 2015 13:59:32 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
On 06/13/15 12:42, Thomas D. Dean wrote:
I am having problems forming a cell array of transfer functions. I
believe the problem is in my lack of understanding cellfun.
In matlab, I would
A0 = 10;
b = 1 / A0; % approximation for ab>>1
R1 = 10000;
R2 = R1 * (1/b - 1)
K = R1/(R1+R2);
C = [1:.2:3]*1e-12;
for n = 1:length(C)
b_array(:,:,n) = tf([K*R2*C(n) K],[K*R2*C(n) 1]);
end
I want to create a cell array, so I tried
b_array=cellfun(@tf,{[K*R2*C K]},{[K*R2*C 1]})
This creates an array with one entry, when I wanted an array of 11
transfer functions.
I finished a preamp using ngspice and thought I could duplicate the
numbers with the control package. I sort-of can do it, but, I can not
seem to get some of the package functions either create cell arrays of
the correct shape or accept cell arrays as arguments.
I tried some other options with no success other than looping.
According to the way I read help cellfun, I should be able to create a
cell array of transfer functions with one line of code. But, I can not.
The plot I want to produce is:
###################################################
a0 = 1e5;
w1 = 1e4;
w2 = 1e6;
s = tf('s');
a = a0/(1+s/w1)/(1+s/w2)
A0 = 10;
b = 1 / A0; % approximation for ab>>1
R1 = 10000;
R2 = R1 * (1/b - 1)
A = feedback(a,b);
K = R1/(R1+R2);
C = [1:.2:3]*1e-12;
hold on
step(A,'r')
hold on
for n=1:length(C)
b_array=tf([K*R2*C(n) K],[K*R2*C(n) 1]);
A_array = feedback(a,b_array);
L_array = a*b_array;
step(A_array,'b')
hold on
endfor
###################################################
I tried to create the cell array with cellfun, but, can not seem to get
the correct shape.
With looping, I created a cell array of transfer functions, but, step()
does not like it.
###################################################
L_array=A_array=b_array=cell(size(C'));
for idx=1:length(C)
b_array{idx,1}=tf([K*R2*C(idx) K],[K*R2*C(idx) 1]);
A_array{idx,1} = feedback(a,b_array{idx,1});
L_array{idx,1} = a*b_array{idx,1};
endfor;
step(A,'r',A_array,'b');
###################################################
Tom Dean
- Forming Cell of systems, Thomas D. Dean, 2015/06/13
- Re: Forming Cell of systems,
Thomas D. Dean <=
- Re: Forming Cell of systems, Thomas D. Dean, 2015/06/14
- Re: Forming Cell of systems, Doug Stewart, 2015/06/14
- Re: Forming Cell of systems, Lukas Reichlin, 2015/06/14
- Re: Forming Cell of systems, Thomas D. Dean, 2015/06/14
- Re: Forming Cell of systems, Thomas D. Dean, 2015/06/14
- Re: Forming Cell of systems, Lukas Reichlin, 2015/06/15