# Help please, I want to avoid a warning message.

2 views (last 30 days)
T Hafid on 16 May 2022
Commented: T Hafid on 16 May 2022
The following Matlab script produce a correct result but with a long warning red text:
-----------------------------------------
% Problem_B_7_3_Modern_Control_Engineering_Katsuhiko_Ogata
clear all
clc
fprintf(' \n')
fprintf('--------------------- \n')
fprintf('Transfer functions \n')
nG1=[1,1]; dG1=[2,1];
G1=tf(nG1,dG1)
nG2=[-1,1]; dG2=[2,1];
G2=tf(nG2,dG2)
fprintf('--------------------- \n')
fprintf('Figure 1 : Body Diagrams \n')
figure(1)
subplot(1,2,1)
bode(G1)
grid on
% From here the problem start
syms s
G1_sym = poly2sym(nG1,s)/poly2sym(dG1,s);
G1_latex = latex(G1_sym);
str1=['$\it {G1(s)=',char(G1_latex),' } \quad$'];
title(str1,'Interpreter','latex','Fontsize',14)
subplot(1,2,2)
bode(G2)
grid on
G2_sym = poly2sym(nG2,s)/poly2sym(dG2,s);
G2_latex = latex(G2_sym);
str2=['$\it {G2(s)=',char(G2_latex),' } \quad$'];
title(str2,'Interpreter','latex','Fontsize',14)
fprintf('--------------------- \n')
--------------------------------------------
How can I avoid the warning message, please.
##### 2 CommentsShowHide 1 older comment
Star Strider on 16 May 2022
This:
text(0.2, 0.5, ['$\it {G1(s)=\frac{\frac{s}{2} + \frac{1}{2}}{s + \frac{1}{2}} } \quad$'], 'Interpreter','latex', 'FontSize',30)
runs without error in R2022a.
I no longer have access to R2015a, so I cannot determine what the problem is with that version.
Be sure you have all the available R2015a updates.

Image Analyst on 16 May 2022
Not sure what "avoid" means, like whether to correct the code so that no warning would be generated, or to leave the code alone but just not have the warning appear in the command window (it would still be generated but just not appear).
For the second, see attached function to suppress various warning messages. There are instructions in there for how to get the code to suppress the particular warning message that you don't want to see.
##### 2 CommentsShowHide 1 older comment
Image Analyst on 16 May 2022
Then my code will do what you want. Follow the directions in the comments to get the error name for your particular error. Sorry I can't do it for you but I don't have the Symbolic Toolbox.
I didn't examine your code for errors. I don't have the Symbolic Toolbox so I can't. But if the problem is minor, it will throw a "warning" in orange text and continue on. That sounds like what is happening with you. If there is a serious problem then it will throw an error in red text and stop because it's impossible for it to continue for some reason. You'll have to fix errors in order to run the code at all. Whether you fix code that causes a warning is up to you, since it still runs. It's optional but not a bad idea.

T Hafid on 16 May 2022
Warning: Error updating Text.
String must have valid interpreter syntax:
$\it {G1(s)=\frac{\frac{s}{2} + \frac{1}{2}}{s + \frac{1}{2}} } \quad$
> In defaulterrorcallback (line 12)
In ctrluis.axesgrid/labelpos (line 26)
In ctrluis.axesgrid/setlabels (line 72)
In mwbypass (line 17)
In title (line 36)
In Problem_B_7_3_Modern_Control_Engineering_Katsuhiko_Ogata (line 25)
Warning: Error updating Text.
String must have valid interpreter syntax:
$\it {G1(s)=\frac{\frac{s}{2} + \frac{1}{2}}{s + \frac{1}{2}} } \quad$
> In defaulterrorcallback (line 12)
In ctrluis.axesgrid/labelpos (line 26)
In ctrluis.axesgrid/setlabels (line 72)
In ctrluis.axesgroup/generic_listeners>LocalSetLabelStyle (line 73)
In mwbypass (line 17)
In title (line 36)
In Problem_B_7_3_Modern_Control_Engineering_Katsuhiko_Ogata (line 25)
Warning: Error updating Text.
String must have valid interpreter syntax:
$\it {G2(s)=-\frac{\frac{s}{2} - \frac{1}{2}}{s + \frac{1}{2}} } \quad$
> In defaulterrorcallback (line 12)
In ctrluis.axesgrid/labelpos (line 26)
In ctrluis.axesgrid/setlabels (line 72)
In mwbypass (line 17)
In title (line 36)
In Problem_B_7_3_Modern_Control_Engineering_Katsuhiko_Ogata (line 34)
Warning: Error updating Text.
String must have valid interpreter syntax:
$\it {G2(s)=-\frac{\frac{s}{2} - \frac{1}{2}}{s + \frac{1}{2}} } \quad$
> In defaulterrorcallback (line 12)
In ctrluis.axesgrid/labelpos (line 26)
In ctrluis.axesgrid/setlabels (line 72)
In ctrluis.axesgroup/generic_listeners>LocalSetLabelStyle (line 73)
In mwbypass (line 17)
In title (line 36)
In Problem_B_7_3_Modern_Control_Engineering_Katsuhiko_Ogata (line 34)

Walter Roberson on 16 May 2022
Question: why are you using \quad there? Why add space at the end of the title?
T Hafid on 16 May 2022
ok
thanks

R2015a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!