matlab程序常用模板

频谱分析

close all;
FF=4.8e4:4.95e4;%数据范围
Hzmax=300; %频率范围
ymax=0.017;%赋值范围\
Fs = 16000;%采样频率
Data = data(FF,:);%采样数据
L = length(Data);
Y = fft(Data);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);%单边谱
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
figure;plot(f,P1);axis([0 Hzmax 0 ymax]);
title('反馈电流频谱');xlabel('频率(Hz)');ylabel('幅值(A)')

simulink到工作空间,数据对比

close all;
xmin = 1;
xmax = 7;
ymin = 900;
ymax = 1200;
LW = 1.4;
%subplot(1,2,1);
plot(P1);hold on;
plot(P2,'--','LineWidth',LW);
legend('正常','参数增加');
% axis([xmin xmax ymin ymax]);
% subplot(1,2,2);
plot(P1);hold on;plot(P3,'--','LineWidth',LW);
legend('正常','参数减小');
% axis([xmin xmax ymin ymax]);

猜你喜欢

转载自blog.csdn.net/qq_34551090/article/details/111450306