Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Zero Padding

Subject: Zero Padding

From: FAISAL PEER MOAHMED

Date: 19 May, 2010 12:45:21

Message: 1 of 8

Hi

I wish to add zeros the end of the signal. I have used horizontal concatenation. Please see the code below.

q= ones(1,1966081 );
w=[q zeros(1023,1)];

It ends up with an error.

Error using ==> horzcat
CAT arguments dimensions are not consistent.

Please help

Regards

Faisal

Subject: Zero Padding

From: Sean

Date: 19 May, 2010 13:00:24

Message: 2 of 8

"FAISAL PEER MOAHMED" <pfaisalbe@gmail.com> wrote in message <ht0mh1$req$1@fred.mathworks.com>...
> Hi
>
> I wish to add zeros the end of the signal. I have used horizontal concatenation. Please see the code below.
>
> q= ones(1,1966081 );
> w=[q zeros(1023,1)];
>
> It ends up with an error.
>
> Error using ==> horzcat
> CAT arguments dimensions are not consistent.



You're trying to concatenate a [1x1966081] with a [1023x1]. It's not going to work:
try:
>> w=[q zeros(1,1023)];

Subject: Zero Padding

From: Wayne King

Date: 19 May, 2010 13:04:07

Message: 3 of 8

"FAISAL PEER MOAHMED" <pfaisalbe@gmail.com> wrote in message <ht0mh1$req$1@fred.mathworks.com>...
> Hi
>
> I wish to add zeros the end of the signal. I have used horizontal concatenation. Please see the code below.
>
> q= ones(1,1966081 );
> w=[q zeros(1023,1)];
>
> It ends up with an error.
>
> Error using ==> horzcat
> CAT arguments dimensions are not consistent.
>
> Please help
>
> Regards
>
> Faisal

Hi, that's because q is a row vector while w is a column vector.

Wayne

Subject: Zero Padding

From: FAISAL PEER MOAHMED

Date: 19 May, 2010 13:16:05

Message: 4 of 8

Thanks. I have tried , same error repeats
 
Regards

Faisal




"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ht0nd8$pbb$1@fred.mathworks.com>...
> "FAISAL PEER MOAHMED" <pfaisalbe@gmail.com> wrote in message <ht0mh1$req$1@fred.mathworks.com>...
> > Hi
> >
> > I wish to add zeros the end of the signal. I have used horizontal concatenation. Please see the code below.
> >
> > q= ones(1,1966081 );
> > w=[q zeros(1023,1)];
> >
> > It ends up with an error.
> >
> > Error using ==> horzcat
> > CAT arguments dimensions are not consistent.
>
>
>
> You're trying to concatenate a [1x1966081] with a [1023x1]. It's not going to work:
> try:
> >> w=[q zeros(1,1023)];

Subject: Zero Padding

From: Doug Hull

Date: 19 May, 2010 13:25:07

Message: 5 of 8

a = [1 2 3];
a(10) = 0

a =

     1 2 3 0 0 0 0 0 0 0


"FAISAL PEER MOAHMED" <pfaisalbe@gmail.com> wrote in message <ht0oak$r20$1@fred.mathworks.com>...
> Thanks. I have tried , same error repeats
>
> Regards
>
> Faisal
>
>
>
>
> "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ht0nd8$pbb$1@fred.mathworks.com>...
> > "FAISAL PEER MOAHMED" <pfaisalbe@gmail.com> wrote in message <ht0mh1$req$1@fred.mathworks.com>...
> > > Hi
> > >
> > > I wish to add zeros the end of the signal. I have used horizontal concatenation. Please see the code below.
> > >
> > > q= ones(1,1966081 );
> > > w=[q zeros(1023,1)];
> > >
> > > It ends up with an error.
> > >
> > > Error using ==> horzcat
> > > CAT arguments dimensions are not consistent.
> >
> >
> >
> > You're trying to concatenate a [1x1966081] with a [1023x1]. It's not going to work:
> > try:
> > >> w=[q zeros(1,1023)];

Subject: Zero Padding

From: Steven Lord

Date: 19 May, 2010 13:27:25

Message: 6 of 8


"FAISAL PEER MOAHMED" <pfaisalbe@gmail.com> wrote in message
news:ht0oak$r20$1@fred.mathworks.com...
> Thanks. I have tried , same error repeats

Then there's something you haven't told us, as given the example as you
wrote it that should work. Execute the following code one line at a time,
copy the entire output from running the code, and paste it into your reply
to this message.

whos q
w = [q zeros(1, 1023)];
whos q w

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Zero Padding

From: FAISAL PEER MOAHMED

Date: 19 May, 2010 13:32:04

Message: 7 of 8

Hi

The error is due to semicolumn. It is necessary to use semicoulmn in the concatenation

Cheers

Faisal








"Steven Lord" <slord@mathworks.com> wrote in message <ht0ovn$bka$1@fred.mathworks.com>...
>
> "FAISAL PEER MOAHMED" <pfaisalbe@gmail.com> wrote in message
> news:ht0oak$r20$1@fred.mathworks.com...
> > Thanks. I have tried , same error repeats
>
> Then there's something you haven't told us, as given the example as you
> wrote it that should work. Execute the following code one line at a time,
> copy the entire output from running the code, and paste it into your reply
> to this message.
>
> whos q
> w = [q zeros(1, 1023)];
> whos q w
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
>

Subject: Zero Padding

From: dpb

Date: 19 May, 2010 14:37:16

Message: 8 of 8

FAISAL PEER MOAHMED wrote:
...
> The error is due to semicolumn. It is necessary to use semicoulmn in the
> concatenation
...

Well, that will solve the problem you had but provides a different
answer than you stated you wanted in being a column instead of a row
vector (array).

You don't seem to be paying any attention to what others pointed out
that the use of zeros(N,1) is a _column_ vector of length N and you
attempted to concatenate that to a row vector. Simply rearranging the
arguments to zeros() _WILL_ solve the initial problem posted as would
the transpose operator (').

The upshot is you have to have consistent dimensions for the operation;
if you want to concatenate by row then the operands must have the same
number of rows; if you want by column the same is true in that
dimension. By extension, to concatenate planes to a 2D array they would
both need to have the same dimensions in both row and column.

The only way around this in Matlab is to use cell arrays to hold varying
dimensioned articles in cells.

--

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us