help-octave
[Top][All Lists]
Advanced

[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: Sun, 14 Jun 2015 13:06:13 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 06/14/15 12:20, Lukas Reichlin wrote:
On 14.06.2015, at 20:49, Thomas D. Dean <address@hidden> wrote:

I am getting closer, I think.

A0 = 10;
b = 1 / A0;
R1 = 10000;
R2 = R1 * (1/b - 1);
K = R1/(R1+R2);
C = [1:.2:3]*1e-12;
a0 = 1e5;
w1 = 1e4;
w2 = 1e6;
s = tf('s');
a = a0/(1+s/w1)/(1+s/w2);
A = feedback(a,b);

#######################################
## still need a cellfun to replace this loop
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]);
endfor;
##
#######################################

A_array=cellfun(@feedback,{a},b_array, 'uniformoutput', false);

function [x]=sys_prod(S1,S2)
  x=S1*S2;
endfunction;

L_array=cellfun(@sys_prod,{a},b_array, 'uniformoutput', false);
[Gm,Pm,Wcg,Wcp] = cellfun(@margin,L_array);

figure 1
step(A,'r',A_array{:});
figure 2
bode(A,A_array{:})
figure 3
plot(C,Pm)

Tom Dean


How about this?


A0 = 10;
b = 1 / A0;
R1 = 10000;
R2 = R1 * (1/b - 1);
K = R1/(R1+R2);
C = [1:.2:3]*1e-12;
a0 = 1e5;
w1 = 1e4;
w2 = 1e6;
s = tf('s');
a = a0/(1+s/w1)/(1+s/w2);
A = feedback(a,b);

b_array = arrayfun (@(C) tf ([K*R2*C, K], [K*R2*C, 1]), C, 'uniformoutput', 
false);

A_array = cellfun (@feedback, {a}, b_array, 'uniformoutput', false);

L_array = cellfun (@mtimes, {a}, b_array, 'uniformoutput', false);

[Gm,Pm,Wcg,Wcp] = cellfun (@margin, L_array);

figure 1
step(A,'r',A_array{:});
figure 2
bode(A,A_array{:})
figure 3
plot(C,Pm)


Yes, that is the solution. Now, it seems obvious to apply arrayfun, since C is an array.

This was the central problem I had. How to form the arguments so I produced the same b_array as the loop.

When I finish the code, I will make it available to include in the control package as an example, it the maintainer wants it.

Tom Dean




reply via email to

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