f



Reproducing MISO ARX model results

I'm stuck at reproducing MISO ARX model results as I'd like to understand the matlab built-in function better. Down is the code with a MISO model with iodelay (nk) in first channel. When I study the case with no delay, the match between matlab built-in function and simulated one are perfect. But with the delays, the match is not even close. Can anyone tell me please where did I go wrong? Thanks.

  clearvars, close all
  %% Reference ARX model
  A  = [1  -1.5  0.7];
  B  = [0 0 0.0001 1 0.5; 0.1 1.2 0.3 0 0];
  m  = idpoly(A,B);
  
 %% Generating data for comparison
  u = iddata([],[idinput(300,'rbs') idinput(300,'rbs')]);
  
  % --- ARX simulation for the reference
  y = sim(m,u);
  z = [y,u];

  %% Reproduction/simulation of the ARX results
  idxA = numel(A)      : -1 : 1;
  idxB = numel(B(1,:)) : -1 : 1; 
  for ct=(1+numel(B(1,:))):numel(z.u(:,1))
      idxA   = idxA + 1;
      idxB   = idxB + 1;    
      y_(ct) = z.u(idxB,1)' * B(1,:)' + z.u(idxB,2)' * B(2,:)' - z.y(idxA(2:end))' * A(2:end)';
  end
  % --- plot results
  figure,plot([z.y y_']),legend('ref','reproduced'); grid on;zoom on;
0
sam
12/23/2016 9:58:03 AM
comp.soft-sys.matlab 211266 articles. 15 followers. lunamoonmoon (258) is leader. Post Follow

1 Replies
106 Views

Similar Articles

[PageSpeed] 18

"sam" wrote in message <o3isfb$hv8$1@newscl01ah.mathworks.com>...
> I'm stuck at reproducing MISO ARX model results as I'd like to understand the matlab built-in function better. Down is the code with a MISO model with iodelay (nk) in first channel. When I study the case with no delay, the match between matlab built-in function and simulated one are perfect. But with the delays, the match is not even close. Can anyone tell me please where did I go wrong? Thanks.
> 
>   clearvars, close all
>   %% Reference ARX model
>   A  = [1  -1.5  0.7];
>   B  = [0 0 0.0001 1 0.5; 0.1 1.2 0.3 0 0];
>   m  = idpoly(A,B);
>   
>  %% Generating data for comparison
>   u = iddata([],[idinput(300,'rbs') idinput(300,'rbs')]);
>   
>   % --- ARX simulation for the reference
>   y = sim(m,u);
>   z = [y,u];
> 
>   %% Reproduction/simulation of the ARX results
>   idxA = numel(A)      : -1 : 1;
>   idxB = numel(B(1,:)) : -1 : 1; 
>   for ct=(1+numel(B(1,:))):numel(z.u(:,1))
>       idxA   = idxA + 1;
>       idxB   = idxB + 1;    
>       y_(ct) = z.u(idxB,1)' * B(1,:)' + z.u(idxB,2)' * B(2,:)' - z.y(idxA(2:end))' * A(2:end)';
>   end
>   % --- plot results
>   figure,plot([z.y y_']),legend('ref','reproduced'); grid on;zoom on;

Found the problem, idxA was defined in a wrong way. Better solution for idxA and idxB within the for-loop:

idxA = ct:-1:ct-numel(A)+1 ;
idxB = ct:-1:ct-numel(B(1,:))+1; 
0
sam
12/23/2016 11:44:04 AM
Reply: