Title causes error when trying to plot graph

For some reason my code won't put a title on the axes. I get the error:
Attempted to access title(104); index out of bounds because
numel(title)=6.
Error in DisplayShift_Fluorescence (line 41)
title('h');
plot(AverageCalibrated(1:32,9),AverageCalibrated(1:32,10))
hold on
plot(AverageNonCalibrated(1:32,9),AverageNonCalibrated(1:32,10),'r')
legend('Calibrated','NonCalibrated')
xlabel('Wavelength')
ylabel('Intensity')
title('h');

 採用された回答

Sean de Wolski
Sean de Wolski 2012 年 11 月 8 日

3 投票

That means you have a variable named title
which title
whos title
To resolve it clear or rename that variable:
clear title

6 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 8 日
the function title was shadowed by the created variable title
Matt Fig
Matt Fig 2012 年 11 月 8 日
One of the top 5 new user errors....
title = 6; % Or whatever
plot(1:10)
title('my plot') % title function is masked by title variable
Sean de Wolski
Sean de Wolski 2012 年 11 月 8 日
@Matt Fig:
regexprep(your_post,' new ',' ')
Ryan
Ryan 2012 年 11 月 8 日
Thanks for the help. I had set title as a variable earlier. Deleted it when I decided to plot, but it was of course still saved in the workspace.
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 8 日
ans =
One of the top 5 user errors....
Matt Fig
Matt Fig 2012 年 11 月 8 日
Sean and Azzi, you guys are probably correct!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by