matlab 非线性辨识,非线性灰盒用Matlab进行系统辨识

最后,我想出了如何在Matlab中使用nlgreyest工具箱。以下代码对我有用:

M = csvread('data/all/data3.txt');

u = [M(:,5), M(:,6)];

y = [M(:,4)* 1/10 * 3.1415/180, M(:,3) * 90/1000 * 3.1415/180 , M(:,2)];

base_elevationInit = y(1,1);

base_pitchInit = y(1,2);

base_travelInit = y(1,3);

%intial guess for the parameters

par = {-1.0000 -2.4000 -0.0943 0.1200 0.1200 -2.5000 -0.0200 0.2 2.1000 10.0000};

order = [3,2,6]; %[Ny Nu Nx]

initialStates =[base_elevationInit, base_pitchInit, base_travelInit, 0, 0, 0]';

Ts = 0;

m = idnlgrey('quan_model_nl',order, par, initialStates, Ts)

m.Parameters(1).Fixed = true;

m.Parameters(2).Fixed = true;

m.Parameters(8).Fixed = true;

m.Parameters(4).Fixed = true;

m.Parameters(5).Fixed = true;

m.Parameters(6).Fixed = true;

m.Parameters(9).Fixed = true;

data = iddata(y,u,0.05);

opt = nlgreyestOptions;

opt.Display = 'on';

opt.SearchOption.MaxIter = 5;

% opt.SearchMethod =

m_est = nlgreyest(data, m, opt)

params = [m_est.Parameters(1).Value m_est.Parameters(2)

和我的模型函数必须保存在与前一个脚本相同的文件夹中名为quan_model_nl.m的文件中。

function [dx,y] = quan_model_nl(t, x, u, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, varargin)

F = [ x(4);

x(5);

x(6);

p1*cos(x(1))+ p2*sin(x(1)) + p3*x(6);

p5*sin(x(2)) + p4*cos(x(2))+ p6*x(5);

p7*x(6);

];

G = [

0 0 ;

0 0 ;

0 0 ;

p8*cos(x(2)) p8*cos(x(2)) ;

p9 -p9 ;

p10*sin(x(2)) p10*sin(x(2)) ;

];

C = [

1,0,0,0,0,0;

0,1,0,0,0,0;

0,0,1,0,0,0;

];

dx = F + G * u';

y = C * x ;

end

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值