Title a plot with variable 'char'
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Title에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!