help-octave
[Top][All Lists]
Advanced

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

Re: Matlab Incompatibility Error Making an Array of TF


From: Lukas Reichlin
Subject: Re: Matlab Incompatibility Error Making an Array of TF
Date: Sat, 13 Jun 2015 11:52:02 +0200

On 13.06.2015, at 10:17, Thomas D. Dean <address@hidden> wrote:
> 
> I attempted to duplicate a (Matlab?) script I found on the web.  The script 
> is at the bottom.
> 
> This demonstrates an incompatibility with Matlab, I believe.
> 
> The error part is marked with ##################
> 
> octave:306> ###########################################
> octave:306> ## this causes an error
> octave:306> K = R1/(R1+R2);
> octave:307> C = [1:.2:3]*1e-12;
> octave:308> for n = 1:length(C)
> >     b_array(:,:,n) = tf([K*R2*C(n) K],[K*R2*C(n) 1]);
> > end
> error: lti: subsasgn: invalid subscripted assignment type
> error: called from
>    subsasgn at line 41 column 7
> error: assignment failed, or no method for '<unknown type> = class'
> octave:308> ###########################################
> 
> 
> I want to do the plot about 4 lines below the error causing block.
> 
> Any work around?
> 
> octave:277> pkg list
> Package Name       | Version | Installation directory
> -------------------+---------+-----------------------
>          control *|   2.8.1 | /home/tomdean/octave/control-2.8.1
>          general *|   1.3.4 | /home/tomdean/octave/general-1.3.4
>           signal *|   1.3.1 | /home/tomdean/octave/signal-1.3.1
> ...
> 
> Tom Dean
> 
> 
> a0 = 1e5;
> w1 = 1e4;
> w2 = 1e6;
> s = tf('s');
> a = a0/(1+s/w1)/(1+s/w2)
> h = bode(a,'r');
> a_norm = a / dcgain(a);
> step(a_norm,'r')
> title('Normalized Open-Loop Step Response');
> ylabel('Normalized Amplitude');
> A  =  1 / b
> A0 = 10;
> b = 1 / A0;    % approximation for ab>>1
> R1 = 10000;
> R2 = R1 * (1/b - 1)
> A = feedback(a,b);
> bodemag(a,'r',A,'b');
> legend('Open-Loop Gain (a)','Closed-Loop Gain (A)')
> ylim([0,110]);
> L = a * b;
> S = 1 / (1 + L);
> S = feedback(1,L);
> bodemag(A,'b',S,'g')
> legend('Closed-Loop Gain(A)', 'System Sensitivity(S)',4)
> step(A)
> margin(L)
> [Gm,Pm,Wcg,Wcp] = margin(L);
> C = 1/(R2*Wcp)
> 
> ###########################################
> ## this causes an error
> 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
> ###########################################
> 
> A_array = feedback(a,b_array);
> L_array = a*b_array;
> 
> step(A,'b:',A_array,'b',[0:.005:1]*1.5e-6);
> title('Closed-Loop Step Response (Compensated)');
> 
> [Gm,Pm,Wcg,Wcp] = margin(L_array);
> plot(C*1e12,Pm,'g');
> ax = gca;
> xlim([0.8 3.6]);
> ylim([45 60]);
> ax.Box = 'on';
> xlabel('Compensation Capacitor, C (pF)');
> ylabel('Phase Margin (deg)')
> 
> A_comp = A_array(:,:,6);
> step(A,'b:',A_comp,'b')
> legend('Uncompensated (0 pF)','Compensated (2 pF)')
> bode(a,'r',A,'b:',A_comp,'b')
> legend('a(s)','A(s)','A\_comp(s)');

Hi Tom,

Arrays are not supported. As a workaround, you can use cells instead. There 
comes an example called «MDSSystem» with the control package which demonstrates 
plotting with cells (line 92).

Hope this helps,
Lukas







reply via email to

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