⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 源程序:.txt

📁 Matlab在化学工程中的应用
💻 TXT
字号:
这是源程序:


clear;
clf;
load zww.mat;       % 导入原始数据
%out=pressure_out;     % 蒸汽压力
%out=tangwen_out;      % 炉膛温度
out=t_zhenqi;          % 蒸汽温度

%--------------------------------------------------------------------
% in,out是原始的输入输出数据,长度和采样间隔可能不匹配,
% 以长度大的为基准重采样,
% in1,out1是重采样后,数据长度匹配的数据
%--------------------------------------------------------------------
if length(in)~=length(out)
    if length(in)<length(out)
        in1=DataResample(in,length(in),length(out));  % match both demision
        out1=out;
    else
        out1=DataResample(out,length(out),length(in));% 以长度大的为基准重采样
        in1=in;
    end
else
    in1=in;
    out1=out;
end


%--------------------------------------------------------------------
% 对in1,out1采用Dtrend分段趋势化方法,作零均值化处理,
% in2,out2为处理后的数据
%--------------------------------------------------------------------
t=[1:length(in1)]';     % 对in1作趋势化处理

clf;
plot(t,in1,'r');        % the inital output figure
hold on;             
in2=dtrend(in1,1,[258 300]);     % 分段线性趋势化[258,300]--2 []--1  []--3
plot(t,in2,'b');          % 消除趋势后的数据           
hold on;
plot(t,in1-in2,'k:');      % 趋势值
             
           %----------------------------------------------------
clf;                    % 对out1作趋势化处理
plot(t,out1,'r');        
hold on;             
out2=dtrend(out1,1,[280]);     % 分段线性趋势化[258,300]--2 []--1  []--3
plot(t,out2,'b');          % 消除趋势后的数据           
hold on;
plot(t,out1-out2,'k:');      % 趋势值


%-----------------------------------------------------------------
na=10;     
nb=na;       % A B的阶次
nk=5;       % 纯延迟
nc=10;        % 噪声模型阶次 

%--------------------------------------------------------------
% 对in2,out2使用arx模型建模,得出二次多项式m_arx
% 使用函数arx(),基于最小二乘估计的ARX模型辨识
%--------------------------------------------------------------
if 0
z0=iddata(out2,in2,14);
m_arx=arx(z0,[na nb nk]);
y_model=sim(m_arx,in2);
v_fpe=fpe(m_arx);
end

%---------------------------------------------------------------
% 对in2,out2使用armax模型建模,得出二次多项式m_armax
% 使用函数armax(),估计ARMAX或ARMA模型的参数
%---------------------------------------------------------------

if 0
    z0=iddata(out2,in2,14);
    m_armax=armax(z0,[na nb nc nk]);   
    y_model=sim(m_armax,in2);
    v_fpe=fpe(m_armax);
end

%---------------------------------------------------------------
% 对in2,out2使用cor_ls模型建模,得出二次多项式m_cor_ls
% 使用函数xcorr()及arx()或armax(),基于相关分析-最小二乘的方法
%---------------------------------------------------------------
if 1 
    u1=xcorr(in2,in2);
    y1=xcorr(in2,out2);
    z1=[y1,u1];      
    m_cor_ls=arx(z1,[na nb nk]);
    y_model=sim(m_cor_ls,in2);       %相关分析
    v_fpe=fpe(m_cor_ls);
    
end

%---------------------------------------------------------------
%
%---------------------------------------------------------------
t=1:1:length(out2);
clf;
plot(t,out2,'b',t,y_model,'k:');  % 显示拟合的函数图形

if 0
hold on;
y1=out2-y_model;
plot(y1,'r');
plot(xcorr(y1));        % 显示残差的自相关函数图形
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -