String of matlab script
3 ビュー (過去 30 日間)
古いコメントを表示
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
2011 年 6 月 22 日
What's a progammist? Apparently they've played a lot of poker according to Google.
採用された回答
Paulo Silva
2011 年 6 月 22 日
\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 件)
Arturo Moncada-Torres
2011 年 6 月 22 日
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 件のコメント
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.
参考
カテゴリ
Help Center および File Exchange で Time Series Events についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!