Title a plot with variable 'char'

4 Ansichten (letzte 30 Tage)
Guilherme Lopes de Campos
Guilherme Lopes de Campos am 11 Mär. 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

Akzeptierte Antwort

Rik
Rik am 11 Mär. 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)
  1 Kommentar
Guilherme Lopes de Campos
Guilherme Lopes de Campos am 11 Mär. 2019
Hi Rik Wisselink,
I got!!,
Thank you very much for help!
Guilherme

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by