필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

If i have an empty pre-allocated 16x11 matrix how can i add headers across the first row?

조회 수: 1 (최근 30일)
me
me 2015년 11월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
I tried this but it didn't work
D = cell(16,11);
d{1}{:} = {'a','b','c','d','e','f','g','h','i','j','k'}

답변 (1개)

Walter Roberson
Walter Roberson 2015년 11월 6일
D = cell(16,11);
D(1,:) = {'a','b','c','d','e','f','g','h','i','j','k'}
  댓글 수: 2
me
me 2015년 11월 6일
편집: me 2015년 11월 6일
Thank you that works great; Do you know if there is a way I can do this with out the heading coming out with the '.... as in the heading being just a instead of 'a' in the matrix?
Walter Roberson
Walter Roberson 2015년 11월 6일
You would have to create a new data class in which each element had an associated flag (or deducible property) that indicated whether it should be output as numeric or as a string without quotes when data of the class was to be displayed. You might be able to subclass it from cell so that you do not have to duplicate all of the other behaviours.
It is the display() method of a class that is called when an element of the class is to be output normally.
Usually you would find it considerably less work to instead write code that displayed the headers and the data and to call the routine at need. Or if you are writing to a file, xlswrite() knows to not put in the quotes.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by