Azzera filtri
Azzera filtri

How to make title function accept dynamic input

4 visualizzazioni (ultimi 30 giorni)
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)

Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by