How to make title function accept dynamic input
조회 수: 3 (최근 30일)
이전 댓글 표시
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에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!