필터 지우기
필터 지우기

Output result in a format.

조회 수: 2 (최근 30일)
C Zeng
C Zeng 2013년 7월 22일
Hello, I would like to let Matlab output the result, the result is several rows, on each row there is name(string), time(string) and value(numeric), however due to the length of each variable of each row, the length varies. So results can be:
'Sun66taken' '22-Jul-2013 14:51:02' [80.5353]
'I H2 taken' '22-Jul-2013 14:51:46' [16.6542]
'Prax taken' '22-Jul-2013 14:51:39' [3.0374]
'Dken' '22-Jul-2013 14:50:40' [18.3594]
'Staken' '22-Jul-2013 12:13:50' [0]
'Wilken' '22-Jul-2013 14:50:40' [0.7917]
---
The command I used is : str=[tag_names(i), num2str(datestr(time{1}(m))), value{1}(m)]; How to modify the code to make it show in a beautiful format, like in Excel, each variable has its fixed blank and no indent.
Thanks.

채택된 답변

Jan
Jan 2013년 7월 22일
편집: Jan 2013년 7월 22일
C = {'Sun66taken' '22-Jul-2013 14:51:02' [80.5353]; ...
'I H2 taken' '22-Jul-2013 14:51:46' [16.6542]; ...
'Prax taken' '22-Jul-2013 14:51:39' [3.0374]; ...
'Dken' '22-Jul-2013 14:50:40' [18.3594]; ...
'Staken' '22-Jul-2013 12:13:50' [0]; ...
'Wilken' '22-Jul-2013 14:50:40' [0.7917]}
CT = C.';
sprintf('%-12s%-22s%g\n', CT{:})
  댓글 수: 2
C Zeng
C Zeng 2013년 7월 23일
Thnaks, Jan, I find out just use "disp(C)" can display them in a good format, right?
C Zeng
C Zeng 2013년 7월 23일
If each row of C is generated in each loop, how to define C and fill in? I am not familiar with character array.
e.g., each row of C is generated each loop, how to write cope to output one row each time into C? Thanks.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by