Hi all,
Can you please help me to understand what does it mean: fprintf('\n%s.%s.%s\n', tt(5:6), tt(3:4), tt(1:2))
I don't know what tt means.... This string is about creation of filelist. I must understand how my script wirks but it's very difficult to me, because I'm not a programmist((((((((((

댓글 수: 2

Sean de Wolski
Sean de Wolski 2011년 6월 22일
What's a progammist? Apparently they've played a lot of poker according to Google.
Alexa Potanina
Alexa Potanina 2011년 6월 22일
Wow, sorry(((((Sometimes I have to speak Russian in my lab and I changed it in my mind and in my brain((((
I mean programmer. I'm biologist.
Sorry))))))
It was very funny, when I read this)))

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

 채택된 답변

Paulo Silva
Paulo Silva 2011년 6월 22일

2 개 추천

\n means new line %s means print a string tt can be a string,vector or array
When you say tt(5:6) you are selection elements inside tt, in this case it's element 5 and 6 where the numbers correspond to the index.
Example
tt='My Array'
tt(5:6) gives you the string 'rr'

댓글 수: 1

Alexa Potanina
Alexa Potanina 2011년 6월 22일
Thank you so much)))))))
I understood it very easy)))

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

추가 답변 (1개)

Arturo Moncada-Torres
Arturo Moncada-Torres 2011년 6월 22일

3 개 추천

tt must be a string (an array of characters) previously defined in your code. What the code line does is display in console the elements of tt on reverse order and with a dot:
fprintf('\n%s.%s.%s\n', tt(5:6), tt(3:4), tt(1:2));
^ ^ ^ ^ ^ ^
|__|__|________| | |
|__|_________________| |
|___________________________|
Try and run the following:
tt = 'aabbcc';
fprintf('\n%s.%s.%s\n', tt(5:6), tt(3:4), tt(1:2));
You will get the following result in console:
cc.bb.aa

댓글 수: 6

Alexa Potanina
Alexa Potanina 2011년 6월 22일
Thanks))))
Paulo Silva
Paulo Silva 2011년 6월 22일
+1 vote, Arturo answer is very good
Alexa Potanina
Alexa Potanina 2011년 6월 22일
Both answers are very good and simple for understanding))))Guys,you must be a teacher cause you explain very good :)
Jan
Jan 2011년 6월 22일
+1: Arturo's answer is very *nice*.
Arturo Moncada-Torres
Arturo Moncada-Torres 2011년 6월 23일
My pleasure. Thanks to all of you =)
Walter Roberson
Walter Roberson 2015년 9월 20일
Kiniena comments
Moncada-Torres illustrates how the code works, and gives a simpler code to explain what the code does.

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

카테고리

도움말 센터File Exchange에서 Just for fun에 대해 자세히 알아보기

질문:

2011년 6월 22일

댓글:

2015년 9월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by