So by combining several tips and tricks from past articles on this website, I have come up with the some code in an attempt to make multi-line titles of multiple step responses (subplots) in one figure with a variable that changes. All of this inside a for loop. Then I got stuck.
Basically what it boils down to: A regular plot can accept multiple-line titles but these response plots cannot. The following code will do what I need it to do:
plot(1:10)title({'First line','Second line'})
However, this will not (where sys is a transfer function)
step(sys)title({'First line','Second line'})
This throws errors:
??? Parameter must be a string.Error in ==> ctrluis.axesgroup.addbypass>localTitle at 25this.Title = string;Error in ==> mwbypass at 18 hh = feval(fcn{:},varargin{:});Error in ==> title at 38 h = mwbypass(ax,'MWBYPASS_title',string,pvpairs{:});Error in ==> title at 23 h = title(gca,varargin{:});
For those who want to pursue what I am doing, here's all of my code:
format longsyms s;t = 1:0.01:10;omega_n = 2.47;zeta = [0.4, 0.7, 1.0, 2.0];for i = 1:length(zeta) N = omega_n^2; D = s^2 + 2*zeta(i)*omega_n*s + omega_n^2; sys = simplify(expand(N/D)); [N, D] = numden(sys); num = sym2poly(N); den = sym2poly(D); sys = tf(num, den); subplot(2,2,i) step(sys, t); subtitle = cellstr(char(['\makebox[4in][c]{' 'Step Response of ' '$$G(s)$$}'],...['\makebox[4in][c]{' '$$\omega_n=2.47$$' ' and ' '$$\zeta=' num2str(zeta(i)) '$$}'])); title(subtitle,... 'FontSize', 12,... 'interpreter', 'latex',... 'FontName', 'Times')end
Best Answer