PI模型
PI迟滞模型的输出公式:
代码记录
此代码为根据PI模型,已知输入(正弦函数幅值为3.5)、阈值以及权重值,利用matlab生成迟滞回线。
%% The Prandtl-Ishlinskii Hysteresis Model-
%% 20241021
clc;clear;
close all;
%% PI Model
%% Define the Input-读取Excel文件进行提取数据列
filename = 'C:\Users\jia\Desktop\yadian\data\test.xlsx';
opts = detectImportOptions(filename);
opts.VariableNamingRule = 'preserve'; % 设置保留原始列名
data = readtable(filename, opts);
t = data{:, 'Time'};
V_val = data{:, 'Value1'};
% L_val = data{:, 'Value2'};
v = V_val'; % 输入信号
%% Thresholds and weights
r=0:0.5:3;
n = length(r); % 阈值个数
P=[0.72 0.6 0.48 0.36 0.24 0.12 0.012]; %weights
%% Play operator Calculation of Fr
Fr=zeros(n,N);
for j=1:1:n
M=max(v(1)-r(j),min(v(1)+r(j),0));
for k=2:1:N
Fr(j,1) = M;
F_inc=v(k);
F_dec=v(k);
A=F_inc-r(j);
B=min(F_dec+r(j),Fr(j,k-1));
Fr(j,k)=max(A,B); % Equation (1)
end%% End sample
end %% End threshold loop
%% The output of PI model
y=P*Fr;
% y(1) = 0;
% y_error=y-L_val';
% H1-真实输入输出与估计输出的比较
h1=figure;
set(h1,'WindowStyle','docked');
hold on
plot(1:N, v, 'b', 'LineWidth', 1.5);
plot(1:N, y, 'r', 'LineWidth', 1.5);
grid on;
xlabel('t','Interpreter','latex')
ylabel('y','Interpreter','latex')
legend('V','real-y');
% H2-绘制真实输出和估计对比
h2=figure;
set(h2,'WindowStyle','docked');
hold on;
plot(v,y,'r','linewidth',1.5);
xlabel('V');ylabel('y');
legend('real-y');