MATLAB绘图中文显示为方框
MATLAB显示英文和字母没有问题,但是当显示中文时会显示乱码,中文显示为方框,如下图:
可以在绘图命令中添加如下代码:
set(gca,'Fontname','Monospaced');
例如:
% 滤波器系数%低通(直接II型4阶、Fs = 1.8e6Hz、Fc = 1.0e4Hz)(阶跃超调)
b = [ 8.869059018931e-08, 3.547623607572e-07, 5.321435411359e-07, 3.547623607572e-07, 8.869059018931e-08];
a = [1, -3.908786943705, 5.730497730452, -3.734525571664, 0.9128162039662];
% 滤波器系数,乘以(2.^26)之后:
Bn = [6, 24, 36, 24, 6];
An = [0,-262314251, 384567193, -250619769, 61258058];
% % % % 滤波器的幅值响应和相角响应
[H, w] = freqz(b,a);
figure('Name','4阶低通b,a滤波器的频率响应')
subplot(211)
plot(Fs*w/(2*pi), abs(H), 'linewidth',1);
xlabel('频率/Hz'); ylabel('幅值/'); grid on
title('幅频特性');
set(gca,'Fontname','Monospaced');
subplot(212)
plot(Fs*w/(2*pi), angle(H)*180/pi, 'linewidth',1)
xlabel('频率/Hz'); ylabel('相位/^o'); grid on
title('相位特性');
set(gca,'Fontname','Monospaced');