Title a plot with variable 'char'
7 views (last 30 days)
Show older comments
Guilherme Lopes de Campos
on 11 Mar 2019
Commented: Guilherme Lopes de Campos
on 11 Mar 2019
Hello MATLAB Community,
I would to title a plot with a variable in workspace, but shows the follow errow:
block= input('which block: '); % ask which block of study, this example 'T250'
[figure1] = createfigure(Index,block); % call function
function [figure1] = createfigure(Y1)
%CREATEFIGURE(Y1)
% Y1: vector of y data
% Auto-generated by MATLAB on 11-Mar-2019 05:54:01
% Create figure
figure1 = figure;
% Create axes
axes1 = axes('Parent',figure1);
hold(axes1,'on');
% Create plot
plot(Y1); title(sprintf('PLOT OF SERIES %s',block));
% Uncomment the following line to preserve the X-limits of the axes
% xlim(axes1,[0 330]);
box(axes1,'on');
% Set the remaining axes properties
set(axes1,'XTick',...
[0 12 24 36 48 60 72 84 96 108 120 132 144 156 168 180 192 204 216 228 240 252 264 276 288 300 312 324],...
'XTickLabel',...
{'1991','1992','1993','1994','1995','1996','1997','1998','1999','2000','2001','2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012','2013','2014','2015','2016','2017','2018'});
end
Error using test_code>createfigure
Too many input arguments.
Error in test_code (line 51)
[figure1] = createfigure(IMCRB,bloco);
Is it possible to insert o code of block without quotes? such as: ('block')
Thank you very much,
Guilherme Lopes
0 Comments
Accepted Answer
Rik
on 11 Mar 2019
Your function declaration must match the use, so you need to put this line at the top of your function instead:
function [figure1] = createfigure(Y1,block)
More Answers (0)
See Also
Categories
Find more on Title in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!