필터 지우기
필터 지우기

display a matrix that contains strings and numbers

조회 수: 3 (최근 30일)
eliza
eliza 2012년 3월 28일
hi
take for example the following:
nameMatrix = {'abc';'ef'}
dataMatrix = [ 1 2 3; 4 5 6]
fullMatrix = {nameMatrix,dataMatrix}
if i want to display the full matrix st i get the following
abc 1 2 3
ef 4 5 6
how can i do that so that they are perfectly aligned. if i use celldisp dont get them aligned..
thanks

채택된 답변

Walter Roberson
Walter Roberson 2012년 3월 28일
fullMatrix = [char(nameMatrix), num2str(dataMatrix)];
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 3월 29일
char([nameMatrix; num2str(dataMatrix)])
However, if you want the names to align with the numbers, then the easiest way is to start using fprintf()
eliza
eliza 2012년 3월 29일
thanks!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by