📄 mimo_msf2df_sim.m
字号:
function mimo_MSF2DF_sim(pnummt,pdenmt,pdeadmt,mnummt,mdenmt,mdeadmt,pdnummt,pddenmt,...
q,order,qnummt,qdenmt,qdeadmt,x,y,Epsilon,Satub,Satlb,qdnum,qdden)
global time st_size M1_handle1 X_handle1 Plot_handle1 figMSF_h
global COLOR_MAP E1_handle1 Keep_handle axis_handle M1_handle2
%MSF Controller
%-----------------------------------------------
[input_delay,dec_M,qdeadmt]=dtarray(mdeadmt,y);
[T,qdeadmt]=transform(qdeadmt);
[Ksp,K,Kdelay,Kspstr,Kstr,Ds,Dstr]=msfgainM(q,order,Epsilon{2},qdeadmt,qnummt,qdenmt,y);
[prefil,prefilnum,prefilden]=prefilcal(Epsilon,order,order);
%Model
%------------------------------------------------
n=length(order);
for i=1:n
for j=1:n
Mnum{i,j}=mt2poly(mnummt{i,j},y);
Mden{i,j}=mt2poly(mdenmt{i,j},y);
Mdead{i,j}=mt2poly(mdeadmt{i,j},y);
end
end
%Process
%-----------------------------------------------
if any(isCellempty(pnummt)) | any(isCellempty(pdenmt))
Pnum=Mnum;
Pden=Mden;
Pdead=Mdead;
else
for i=1:n
for j=1:n
Pnum{i,j}=mt2poly(pnummt{i,j},x);
Pden{i,j}=mt2poly(pdenmt{i,j},x);
Pdead{i,j}=mt2poly(pdeadmt{i,j},x);
end
end
end
%Pd
%------------------------------------------------
for i=1:n
for j=1:n
Pdnum{i,j}=mt2poly(pdnummt{i,j},y);
Pdden{i,j}=mt2poly(pddenmt{i,j},y);
Pddead{i,j}=0;
end
end
color_step=round(64/n/n)-1;
options = simset('SrcWorkspace','current','MaxStep',st_size);
sim_fun=['mimoMSF2df' num2str(n)];
if ~get(Plot_handle1(2),'Value') & length(figMSF_h) > 1
for i=2:length(figMSF_h)
if ishandle(figMSF_h(i))
delete(figMSF_h(i));
end
end
figMSF_h(2:end)=[];
end
first_fig_taken=0;
for j=1:n
Setpoint=zeros(1,n); Disturb=Setpoint;
if get(Plot_handle1(1),'Value')==1
Setpoint(j)=1;
else
Disturb(j)=1;
end
[t]=sim(sim_fun,time,options);
plot_fig=0;
for i=1:n
bg_color=get(M1_handle1(n*(i-1)+j),'Backgroundcolor');
if ~all(bg_color==[1 1 1])
plot_fig=1;
end
end
if plot_fig
if get(Plot_handle1(2),'Value') | first_fig_taken
temp=get(gcf,'Position');
tmp=length(figMSF_h)+1;
figMSF_h(tmp)=crfig(temp(1)+20,temp(2)+temp(4)-445,600,440,...
'Time Response of the Model State Feedback MIMO system',...
[.5 .55 .6],'figure','on');
M1_handle2(:,tmp)=Xuiarray([80 415 15*n 15],1,n,0,[0],...
'push','p_index=1;imcmenuM;','','',4710,figMSF_h(tmp));
ax_h(1)=subplot(2,1,1);grid on
title(['Control efforts when only setpoint ' num2str(j) ' is active.']);
set(gca,'color',[.55 .55 .65]);
xlabel('Time');
ylabel('Control efforts');
ax_h(2)=subplot(2,1,2);grid on
ylabel('Outputs ( i )');
xlabel(['(Plant parameter x = ' lessblnk(num2str(x)) ' )']);
set(gca,'color',[.55 .55 .65]);
else
first_fig_taken=1;
figure(figMSF_h(1));
ax_h(1)=axis_handle(1,1);
ax_h(2)=axis_handle(2,1);
if ~get(Keep_handle,'Value')
axes(ax_h(1)); cla;grid on
title(['Control efforts when only setpoint ' num2str(j) ' is active.']);
axes(ax_h(2)); cla;grid on
end
end
for i=1:n
bg_color=get(M1_handle1(n*(i-1)+j),'Backgroundcolor');
tmp=COLOR_MAP((n*(i-1)+j)*color_step,:);
set(M1_handle2(i,length(figMSF_h)),'Backgroundcolor',tmp);
set(M1_handle2(i,length(figMSF_h)),'String',num2str(i));
if ~all(bg_color==[1 1 1])
axes(ax_h(1)); hold on
plot(t,sat_effort(:,i),'color',tmp);
axes(ax_h(2)); hold on
plot(t,yout(:,i),'color',bg_color);
else
axes(ax_h(1)); hold on
plot(t,sat_effort(:,i),'color',tmp);
end
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -