image thumbnail
from Wind Turbine System Identification by Sumit Tripathi
Use system Identification techniques to predict power generation from wind turbine.

[parsol]=ARX_model(mb,na,u_in,y_out)
function [parsol]=ARX_model(mb,na,u_in,y_out)

% ARX Process-----------------------------
L=length(u_in);
u_in_ID=u_in;
y_out_ID=y_out;
n=length(y_out_ID)-mb;
I=eye(n,1)+1;
I(1)=I(1)-1;
A=I; % Initialize Matrix A
Y=y_out_ID((mb+1):end); % Defining Y vector
% Put output delay 1 to mb-na in A matrix
for k=1:1:mb-na
    A=[A y_out_ID((mb-k+1):(end-k))];
end
% Put "Current Input -- mbth delayed Input" to Matrix A
for p=1:1:mb
    k=p-1;
    A=[A u_in_ID((mb-k+1):(end-k))];
end
A(:,1)=[]; % Delete 1st column of Matrix A, which was used to Initialize it
% parsol=inv(A'*A)*A'*Y
parsol=pinv(A)*Y;
return

Contact us at files@mathworks.com