Matlab plot label's text is unreadable

僤鯓⒐⒋嵵緔 提交于 2019-12-11 11:59:37

问题


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:

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


回答1:


Your code works fine and renders properly on my machine. It looks like a problem with your graphics driver or hardware. Here are two possible solutions:

Update drivers

Update your graphics driver to the latest version. This might solve the problem already.

OpenGL

On Windows and Linux you can use OpenGL instead of the systems hardware to render the graphics. Therefore you can execute the following command, so Matlab opens in OpenGL-mode in the future:

opengl('save','software')

If you want to start Matlab using the systems hardware, use the following command to change it back:

opengl('save','hardware')

In case you just want to start Matlab in OpenGL-mode once, you can open Matlab in the command prompt of your operation system with the -softwareopengl argument:

matlab -softwareopengl


来源:https://stackoverflow.com/questions/31070818/matlab-plot-labels-text-is-unreadable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!