필터 지우기
필터 지우기

Putting transfer function expression in the title of a bode plot

조회 수: 1 (최근 30일)
Hi
I am trying to put a transfer function expression in the title of a bode plot.
This code worked in 2010b.
I am now using R2019a so this is the version my question applies to.
the code:
num=[1 2];
den=[1 7 49];
trans=tf(num,den);
syms s
n = sym(num);
d = sym(den);
ns = poly2sym(n,s);
ds = poly2sym(d,s);
tfsym = ns/ds;
tftitle = latex(tfsym);
figure(1)
bode(trans)
title(sprintf('Bode plot of: $$ %s $$', tftitle), 'Interpreter','latex')
It works but gives the following warnings:
String scalar or character vector must have valid interpreter syntax:
Bode plot of: $$ \frac{1}{s^2+2\,s+1} $$
> In defaulterrorcallback (line 12)
In ctrluis.axesgrid/labelpos (line 26)
In ctrluis.axesgrid/setlabels (line 83)
In ctrluis.axesgroup/addbypass>localTitle (line 24)
In mwbypass (line 17)
In title (line 49)
In bode (line 22)
Anyone any ideas?
Thank you
tgahan

채택된 답변

Subhadeep Koley
Subhadeep Koley 2019년 8월 2일
MATLAB provides bodeoptions to add various parameters to your bode plot.
The following code may help you.
tfsym = ns/ds;
tftitle = latex(tfsym);
figure(1)
opts=bodeoptions;
opts.Title.Interpreter = 'latex';
opts.Title.FontSize = 12;
opts.XLabel.FontSize = 12;
opts.YLabel.FontSize = 12;
opts.Title.String = sprintf('Bode plot of: $$ %s $$', tftitle);
bodeplot(trans,opts);
  댓글 수: 1
Thomas Gahan
Thomas Gahan 2019년 9월 3일
Apologies for the late reply, was on vacation.
Thank you very much for your expert assistance.
This worked perfect.
Kind regards
tgahan

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by