필터 지우기
필터 지우기

Creating a char matrix

조회 수: 51 (최근 30일)
chaos4u2
chaos4u2 2013년 2월 11일
I need to build a char matrix, for example:
A = [31T 31T 31T ...] Of dimensions 1514443x1 full of '31T'.
I would write: for i=1:1514443; A(i,1)='31T'; end
But I get the mistake: Assignment has more non-singleton rhs dimensions than non-singleton subscripts
I don't know what to do. Please help me.

채택된 답변

José-Luis
José-Luis 2013년 2월 11일
편집: José-Luis 2013년 2월 11일
your_mat = repmat('31T',15443,1);
Note that the dimensions of this array will be 15443 times 3 (the number of characters in the string. If you really want a 1 as the second dimension then you could use a cell array:
your_mat = repmat({'31T'},15443,1);
  댓글 수: 2
chaos4u2
chaos4u2 2013년 2월 12일
Thank you!!
José-Luis
José-Luis 2013년 2월 12일
My pleasure

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 11일
s='31T'
out=repmat(s,1514443,1)
  댓글 수: 1
chaos4u2
chaos4u2 2013년 2월 11일
Thank you very much!!!! Problem solved!

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

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by