How to make title function accept dynamic input
2 ビュー (過去 30 日間)
古いコメントを表示
Chuzymatics Chuzymatics
2014 年 9 月 14 日
コメント済み: Chuzymatics Chuzymatics
2014 年 9 月 14 日
I want the code below to generate plot for each subject entered and display the subject name accepted during run time as the title of the plot. Matlab complains about the title line input argument. Please help
clf
%Accept the time vector
year = 2008:2014
% Accept the subject to be plotted
subject = input('Please input/enter the subject', 's');
%Accept grade A inputs
A_score = input('Enter A grades, a 1 x 7 vector:');
%Accept grade B inputs
B_score= input('Enter B grades , a 1 x 7 vector:');
%Accept grade C inputs
C_score= input('Enter C grades, a 1 x 7 vector:');
D_score= input('Enter D grades, a 1 x 7 vector:');
E_score= input('Enter E grades, a 1 x 7 vector:');
F_score= input('Enter F grades, a 1 x 7 vector:');
%Generate the multiplots
plot(year, A_score, '-sk', year, B_score, '->g', year, C_score, '-+b', year, D_score, '-*c',
year, E_score, '-oy', year, F_score, '-dr', 'linewidth', 3)
set(gca, 'LineWidth', 3)
set(gcf, 'Units','Normalized', 'OuterPosition', [0 0 1 1]);% Code enlarges the figure/axes
legend('A-Scores', 'B-Scores', 'C-Scores', 'D-Scores', 'E-Scores' ,'F-Scores')
xlabel('Examination Dates')
ylabel('Total Number of Grades Obtained')
title('Graphical Display of Chuzymatics:', subject)
0 件のコメント
採用された回答
Mischa Kim
2014 年 9 月 14 日
編集済み: Mischa Kim
2014 年 9 月 14 日
Use
title(strcat('Graphical Display of Chuzymatics: ', subject))
which concetanates the two strings to be outputted as title.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Financial Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!