How to make title function accept dynamic input

15 views (last 30 days)
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)

Accepted Answer

Mischa Kim
Mischa Kim on 14 Sep 2014
Edited: Mischa Kim on 14 Sep 2014
Use
title(strcat('Graphical Display of Chuzymatics: ', subject))
which concetanates the two strings to be outputted as title.

More Answers (0)

Categories

Find more on Financial Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!