Title a plot with variable 'char'

4 ビュー (過去 30 日間)
Guilherme Lopes de Campos
Guilherme Lopes de Campos 2019 年 3 月 11 日
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

採用された回答

Rik
Rik 2019 年 3 月 11 日
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 件のコメント
Guilherme Lopes de Campos
Guilherme Lopes de Campos 2019 年 3 月 11 日
Hi Rik Wisselink,
I got!!,
Thank you very much for help!
Guilherme

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by