Rotate Individual Letters in a String

Hello! I wonder if there is a way to have the word SINE rotated 90% counter-clockwise and each of the letters 90% clockwise so that the letters stand normal on oneanother like:
E N I S
Thanks!

 채택된 답변

Jan
Jan 2012년 1월 24일

2 개 추천

Does this help:
S = 'SINE';
C = cell(1, numel(S));
for i = 1:numel(S)
C{i} = S(i);
end
% >> C = {'E', 'N', 'I', 'S'}
text(0.5, 0.5, C);
? I'm still not sure, what you want to achieve.

댓글 수: 1

Dima
Dima 2012년 1월 24일
Brilliant!!!! this one worked! thanks so much!!))) can you please explain to me how this code works?
My aim is to place vertical text markers on MULTIPLE points in a chart so I used a code like this:
text(Num(7:end2,1)-1,Num(7:end2,77),'S1')
now I just replaced it to work in the for-end way:
for j=7:end2
text(j,Num(j,76),C,'FontSize',2,'Color','W','VerticalAlignment','middle','HorizontalAlignment','center','Rotation',0,'BackgroundColor',[1,0.4,0.6]);
end
and it works superb!!! I now just need to generate separate word strong for each point from
S = 'SINE';
C = cell(1, numel(S));
for i = 1:numel(S)
C{i} = S(i);
end

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

추가 답변 (3개)

bym
bym 2012년 1월 23일

1 개 추천

t = 'sine'
flipud(t')
ans =
e
n
i
s

댓글 수: 2

Dima
Dima 2012년 1월 23일
thanks...but when I try to text the oputput of flipud(t') it gives the same error:
??? Error using ==> text
Each string specified must have a corresponding set of coordinates
bym
bym 2012년 1월 24일
what are your x y arguments passed to text()?

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

Dima
Dima 2012년 1월 23일

0 개 추천

I found a way to create the vertical string :
t1 = 'S'; t2 = 'I'; t3 = 'N'; t4 = 'E';
S1 = char(t1, t2, t3);
But when I try to text this string I get the following error:
??? Error using ==> text
Each string specified must have a corresponding set of coordinates
I wonder what is the reason for this error?
Thanks!

댓글 수: 4

Walter Roberson
Walter Roberson 2012년 1월 23일
Your S1 assignment is the same as
S1 = 'SIN' .';
(No E because you did not include t4 in your char() call)
"help text" is more clear on the reason you are getting the error:
"If 'string' is an array the same number of rows as the
length of X and Y, TEXT marks each point with the corresponding row of the 'string' array."
Your array did not have the same number of rows as the length of x and y as you only passed one x and y each probably.
You will have to position the characters individually; text() does not have a mechanism to automatically position the characters in the manner you would like.
Dima
Dima 2012년 1월 23일
sorry I meant:
S1 = strvcat(t1, t2, t3);
Walter Roberson
Walter Roberson 2012년 1월 23일
char() with multiple single-character arguments turns out to do vertical cat anyhow.
Dima
Dima 2012년 1월 24일
you think it is impossible to rotate the text in this way with no function whatsoever?

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

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2012년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by