Using dynamic subscripts in plot title

조회 수: 6 (최근 30일)
Earl
Earl 2012년 4월 15일
편집: Carlos A. Morales Rergis 2014년 2월 18일
I want to use subscripts in a plot title, but the value I want to use changes, depending on the subplot. E.g. If I have 3 subplots (varies) then I want the first plot's title to look like:
title('x_1')
and the second to be:
title('x_2')
etc. I have the value for the subscript in a variable, say i, but how do I set this as a subscript? If I try:
title('x_i')
MatLab interprets the 'i' literally of course. What is the correct way?

채택된 답변

Walter Roberson
Walter Roberson 2012년 4월 15일
title(sprintf('x_%d', i))
  댓글 수: 2
Earl
Earl 2012년 4월 15일
Thank you!
Carlos A. Morales Rergis
Carlos A. Morales Rergis 2014년 2월 18일
편집: Carlos A. Morales Rergis 2014년 2월 18일
Hello, I have a question:
What happens when i > 9?
How to insert subscript two or three symbols?
e.g:
title(' x_1_2 ')
Thank you a lot!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Title에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by