How do I use a string for the argument in legend()?

조회 수: 12 (최근 30일)
Anthony Mittas
Anthony Mittas 2015년 7월 22일
답변: Star Strider 2015년 7월 22일
I have created this string: legend_string = ['g-Switch High', 'g-Switch Low']; I would like to use it like this: legend(legend_string) to plot 2 legend lines (blue line - g-Switch High, red line - g-Switch Low). What I get is one legend line with 'g-Switch High', 'g-Switch Low' as the display.

채택된 답변

Star Strider
Star Strider 2015년 7월 22일
The square brackets [] concatenate character arrays. Making a cell array out of them will display them as you want them:
legend_string = {'g-Switch High', 'g-Switch Low'};

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by