필터 지우기
필터 지우기

How to build a table with words and numbers?

조회 수: 2 (최근 30일)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2019년 4월 11일
댓글: MAHMOUD ALZIOUD 2019년 4월 15일
Dear All, I am having hard time trying to build a table on MATLAB that consists of words and numbers, the numbers I have them as vectors but I need to add the labels, what is the best way to do that? I attached the small table I am trying to make.
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 4월 11일
When you say you want to build a table, please indicate which of these you are trying to do:
  1. Create a .xls or .xlsx file that has a mix of text and numbers in the cells
  2. Create a uitable graphics object that has a mix of text and numbers in the cells
  3. Create a cell array that has a mix of text and numbers in the cells
  4. Create a numeric array that has a mix of text and numbers
  5. Create a table() object that has a mix of text and numbers in the entries (if so, is it acceptable to use JAN FEB and so on as the names of the variables?)
  6. Create some kind of array that is not numeric and not a cell array or table() object but when you use regular () indexing of it, then indexing at column 1 or row 1 should give text objects but regular () indexing of the other rows and columns should give numeric results
  7. Display as text in the command window a nicely aligned display that has a mix of text and numbers in it
  8. Write as a text file a nicely aligned display that has a mix of text and numbers in it
  9. Display on a plot a nicely aligned display that has a mix of text and numbers in it
Most of these are possible, but not all of them. You cannot (usefully) put text into a numeric array. Creating an array that is not numeric or cell array or table object in which () indexing is intelligent about what it returns would require writing a new kind of data class that might not be compatible with most existing numeric uses.
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2019년 4월 12일
Dear Mr. Walter, you are right I forgot to mention the details, what I need is to build a table in MATLAB and convert it to a text file, I attached now an example of the required output files Sir.

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

채택된 답변

Walter Roberson
Walter Roberson 2019년 4월 14일
The easiest approach is to write the file yourself. fopen(), fprintf() the header. The most straight-forward approach after that is to loop fprintf() one line at a time. There are other approaches that can handle fprintf() of entire arrays of mixed data types, but the methods are more complex to set up and more complex to understand.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by