日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab 参数识别,[转载]自编最小二乘法的Matlab参数辨识程序(含实例)

發布時間:2025/3/12 循环神经网络 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab 参数识别,[转载]自编最小二乘法的Matlab参数辨识程序(含实例) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

function [sysd,sys,err] = ID(Y,U,Ts)

%

%基于遞推最小二乘法的參數辨識程序

%僅針對二階系統:)

%出處:http://blog.sina.com.cn/xianfa110

%=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=

%Inputs:

%=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=

%Y = nX1 vector of your model output

%U = nX1 vector of your model input

%Ts = sample time

%

%=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=

%Outputs:

%=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=

%sysd = discrete-time transfer function identified

%sys = continuous-time transfer function identified

%err = error

%

if nargin<3 || nargin>3

error('Must be three inputs!');

end

if length(Y)~=length(U)

error('length of inputs must be equal.');

end

n=length(U);

Y=reshape(Y,n,1);

U=reshape(U,n,1);

theta=[0.1;0.1;0.1;0.1;0.1];

P=2^25*eye(5);

R0=1;

for m=3:n

X=[Y(m-1) Y(m-2) U(m) U(m-1) U(m-2)]';

alfa=1/(R0+X'*P*X);

L=alfa*P*X;

theta(:,m-1)=theta(:,m-2)+L*(Y(m)-X'*theta(:,m-2));

P=P/R0-alfa*P*X*X'*P;

err=Y(m)-X'*theta(:,m-2);

if abs(err)<=1e-10

break;

end

end

m=length(theta(1,:));

result=[-theta(1:2,m);theta(3:5,m)];

t=1:m;

figure;

plot(t,theta(1,:),t,theta(2,:),t,theta(3,:),t,theta(4,:),t,theta(5,:));

legend('th1','th2','th3','th4','th5');

num=[result(3),result(4),result(5)];

den=[1,result(1),result(2)];

sysd=tf(num,den,Ts);

[n,d]=d2cm(num,den,Ts,'tustin');

sys=tf(n,d);

%%====================================================

exaple:

對于以下模型:

運行之后,數據通過Scope傳遞到工作空間,方法參見Simulink利用Scope輸出及繪制仿真波形技巧。

輸入以下代碼:

Y=data(:,3);U=data(:,2);

[sysd,sys,e]=ID(Y,U,0.001);

得到結果如下:

Transfer function:

-4.314e-009 z^2 + 8.784e-005 z + 4.362e-005

-------------------------------------------

z^2 - 1.975

z + 0.9753

Sampling time: 0.001

Transfer function:

-1.12e-005 s^2 - 0.04417 s + 133.1

----------------------------------

s^2 + 25.02 s - 0.008906

e =

-6.8120e-011

相關文章:

總結

以上是生活随笔為你收集整理的matlab 参数识别,[转载]自编最小二乘法的Matlab参数辨识程序(含实例)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。