필터 지우기
필터 지우기

How to make title function accept dynamic input

조회 수: 3 (최근 30일)
Chuzymatics Chuzymatics
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)

채택된 답변

Mischa Kim
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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by