adding a padding to matrix.

for example, i have a vector A = [ which has 43 elements ]
if i use reshape (A,9,5)
there is an error since i lack 2 elements to make a 5x9 table. how do i add empty elements to the matrix?

댓글 수: 1

Portgas Ace
Portgas Ace 2012년 9월 30일
so there is a value of a matrix which will only be a space.

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

답변 (1개)

Matt J
Matt J 2012년 9월 30일
편집: Matt J 2012년 9월 30일

0 개 추천

You haven't specified where the padding should go (beginning/end) and with what values, but this should give you the idea:
A(45)=0; %pad the vector with zeros
B=reshape (A,9,5)

댓글 수: 2

Portgas Ace
Portgas Ace 2012년 9월 30일
could i possibly do
A(45)= ' ' %pad with only a blank
also, is there any other way to put the paddings on random places.
Matt J
Matt J 2012년 9월 30일
With cell arrays, you can do something like that,
A=num2cell(A);
A{45}=[]; %pad with empty
B=reshape(A,9,5);
As for "padding in random places", you can do things like this:
A=num2cell(A);
B=cell(9,5);
B(1:20)=A(1:20);
B(23:end)=A(21:end);

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2012년 9월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by