필터 지우기
필터 지우기

Multiple Line Title and Variable insertion

조회 수: 1 (최근 30일)
Anas Deiranieh's
Anas Deiranieh's 2017년 3월 13일
답변: Star Strider 2017년 3월 13일
I can't get the last set of strings to stay on the same line as the variable i just inserted. I've tried [] {} and () brackets with no luck.
ThisNumber = 50;
x = [1:200];
Wave1 = sin(x);
Wave2 = cos(x);
plot(Wave1,Wave2)
title({'This is the first line','The total size of this is' int2str(ThisNumber) 'cm'})
This is the output
This is the first line
The total size of this is
50
cm
I need it to look like
This is the First Line
The total size of this is 50cm

채택된 답변

Star Strider
Star Strider 2017년 3월 13일
It is easier to do this with the sprintf funciton:
title(sprintf('This is the first line\nThe total size of this is %d cm', ThisNumber))

추가 답변 (1개)

KSSV
KSSV 2017년 3월 13일
ThisNumber = 50;
x = [1:200];
Wave1 = sin(x);
Wave2 = cos(x);
plot(Wave1,Wave2)
title({'This is the first line',strcat('The total size of this is', int2str(ThisNumber),'cm')})

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by