Matlab plot label's text is unreadable

时间:2015-06-26 10:25:14

标签: matlab plot matlab-figure

first of all, I'm a newbie with Matlab. I just use it because I need the Control System Toolboox for my university.

Yesterday, I launched this script:

%
% Esempio 11.2
%
clear all
close all
clc
%
numG=10;
denG=conv([10 1],[5 1]);denG=conv(denG,[1 1]);
G=tf(numG,denG);
%
numRA=8*denG;
denRA=conv([250 1],[0.4 1]);denRA=conv(denRA,[0.4 1]);
RA=tf(numRA,denRA);
numRB=8*conv([10 1],[5 1]);
denRB=conv([250 1],[0.4 1]);
RB=tf(numRB,denRB);
numRC=8*conv([5 1],[1 1]);
denRC=conv([0.02 1],[0.02 1]);
RC=tf(numRC,denRC);
numRD=0.025*conv([10 1],[5 1]);
denRD=[1 1 0];
RD=tf(numRD,denRD);
%
LA=G*RA;
LB=G*RB;
LC=G*RC;
LD=G*RD;
% calcolo margini di guadagno e di fase
[kmA,pmA,wpA,wcA]=margin(LA);
[kmB,pmB,wpB,wcB]=margin(LB);
[kmC,pmC,wpC,wcC]=margin(LC);
[kmD,pmD,wpD,wcD]=margin(LD);
% calcolo massimo ritardo tollerabile
tauA=(pmA/wcA)*pi/180;
tauB=(pmB/wcB)*pi/180;
tauC=(pmC/wcC)*pi/180;
tauD=(pmD/wcD)*pi/180;
%
FA=LA/(1+LA);
FB=LB/(1+LB);
FC=LC/(1+LC);
FD=LD/(1+LD);
%
QA=RA/(1+LA);
QB=RB/(1+LB);
QC=RC/(1+LC);
QD=RD/(1+LD);
%
% Figura 11.4
w=logspace(-2,2,1000);
[mL1,pL1]=bode(8*G,w);
mL1=20*log10(mL1);
mL1=squeeze(mL1)';
pL1=squeeze(pL1)';
subplot(211),semilogx(w,mL1),grid
xlabel('\omega'),ylabel('dB')
subplot(212),semilogx(w,pL1),grid
xlabel('\omega'),ylabel('gradi')
% Figura 11.6
w=logspace(-2,2,1000);
[mLC,pLC]=bode(LC,w);
mLC=20*log10(mLC);
mLC=squeeze(mLC)';
pLC=squeeze(pLC)';
figure
subplot(211),semilogx(w,mLC),grid
xlabel('\omega'),ylabel('dB')
subplot(212),semilogx(w,pLC),grid
xlabel('\omega'),ylabel('gradi')
% Figura 11.8
w=logspace(-2,2,1000);
[mRA,pRA]=bode(RA,w);
mRA=20*log10(mRA);mRA=squeeze(mRA)';pRA=squeeze(pRA)';
[mRB,pRB]=bode(RB,w);
mRB=20*log10(mRB);mRB=squeeze(mRB)';pRB=squeeze(pRB)';
[mRC,pRC]=bode(RC,w);
mRC=20*log10(mRC);mRC=squeeze(mRC)';pRC=squeeze(pRC)';
[mRD,pRD]=bode(RD,w);
mRD=20*log10(mRD);mRD=squeeze(mRD)';pRD=squeeze(pRD)';
figure
subplot(211),semilogx(w,mRA,w,mRB,w,mRC,w,mRD),grid
xlabel('\omega'),ylabel('dB')
legend('A','B','C','D')
subplot(212),semilogx(w,pRA,w,pRB,w,pRC,w,pRD),grid
xlabel('\omega'),ylabel('gradi')
legend('A','B','C','D')
% Figura 11.9
t=0:0.01:25;
yA=step(FA,t);
yB=step(FB,t);
yC=step(FC,t);
yD=step(FD,t);
figure
plot(t,yA,t,yB,t,yC,t,yD),grid
xlabel('t'),ylabel('y')
legend('A','B','C','D')
% Figura 11.10
t=0:0.01:5;
uA=step(QA,t);
uB=step(QB,t);
uC=step(QC,t)/1e4;
uD=step(QD,t);
figure
plot(t,uA,t,uB,t,uC,t,uD),grid
xlabel('t'),ylabel('u')
legend('A','B','C (x10^4)','D')
% Figura 11.11
Gp=G*tf(4,[1 0.4 4]);
FpA=RA*Gp/(1+RA*Gp);
FpB=RB*Gp/(1+RB*Gp);
FpC=RC*Gp/(1+RC*Gp);
FpD=RD*Gp/(1+RD*Gp);
t=0:0.01:25;
yA=step(FpA,t);
yB=step(FpB,t);
yC=step(FpC,t);
yD=step(FpD,t);
figure
plot(t,yA,t,yB,t,yC,t,yD),grid
xlabel('t'),ylabel('y')
axis([0 25 0 1.2])
legend('A','B','C','D')
% Figura 11.12
t=0:0.01:25;
yrif=ones(size(t));
n=sin(2*t);
yA=lsim(FA,yrif-n,t);
yB=lsim(FB,yrif-n,t);
yC=lsim(FC,yrif-n,t);
yD=lsim(FD,yrif-n,t);
figure
plot(t,yA,t,yB,t,yC,t,yD),grid
xlabel('t'),ylabel('y')
legend('A','B','C','D')

Now, each time i plot something with 'bode' function or 'nyquist' function, or simply 'plot' function, appears like this: enter image description here enter image description here

What can I do to solve this problem? Thank you!

1 个答案:

答案 0 :(得分:3)

您的代码运行正常并在我的计算机上正常呈现。它看起来像您的图形驱动程序或硬件的问题。以下是两种可能的解决方案:

更新驱动程序

将您的图形驱动程序更新到最新版本。这可能已经解决了这个问题。

的OpenGL

在Windows和Linux上,您可以使用OpenGL而不是系统硬件来渲染图形。因此,您可以执行以下命令,以便将来在OpenGL模式下打开Matlab:

opengl('save','software')

如果要使用系统硬件启动Matlab,请使用以下命令将其更改回来:

opengl('save','hardware')

如果您只想在OpenGL模式下启动Matlab一次,可以使用-softwareopengl参数在操作系统的命令提示符中打开Matlab:

matlab -softwareopengl