필터 지우기
필터 지우기

How to use string with different sizes as a text in figure?

조회 수: 1 (최근 30일)
MP
MP 2022년 7월 28일
댓글: KSSV 2022년 7월 28일
I have three Char matrix say, S1 (1x112), S2 (1x26) and S3 (1x36), all three are different sizes.
I would like to put S1, S2 and S3 as a text in a figure such that S1 is in the first line, S2 in the second and S3 in the third line.
When I run
str = [S1; S2; S3]
it says,
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
% i would like to run
text(0.5,1.5,str);
How to use this as a text in figure?

채택된 답변

KSSV
KSSV 2022년 7월 28일
str1 = 'I' ;
str2 = 'Love' ;
str3 = 'MATLAB' ;
str = sprintf('%s\n%s\n%s',str1,str2,str3);
[X,Y,Z] = peaks(50) ;
pcolor(X,Y,Z)
shading interp
text(0,0,str)
  댓글 수: 2
MP
MP 2022년 7월 28일
Thank you so much @KSSV
KSSV
KSSV 2022년 7월 28일
Thanks is accepting/ voting the answer... :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by