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:
How to Null an array

Subject: How to Null an array

From: dderijken

Date: 3 Dec, 2002 08:05:15

Message: 1 of 12

Hi,

I have an array for example:

A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]

How can make N last numbers to be zero like this :
for example N=5

A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]

Thanks

Subject: How to Null an array

From: Matt Wolinsky

Date: 3 Dec, 2002 02:11:54

Message: 2 of 12

dderijken wrote:
>
>
> Hi,
>
> I have an array for example:
>
> A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
>
> How can make N last numbers to be zero like this :
> for example N=5
>
> A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
>
> Thanks
>
>


A(end-N:end)=0;

Subject: How to Null an array

From: Herbert Ramoser

Date: 3 Dec, 2002 08:28:39

Message: 3 of 12

Matt Wolinsky wrote:
> dderijken wrote:
>
>>
>>Hi,
>>
>>I have an array for example:
>>
>>A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
>>
>>How can make N last numbers to be zero like this :
>>for example N=5
>>
>>A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
>>
>>Thanks
>>
>>
>
>
>
> A(end-N:end)=0;

You are close:
A(end-N+1:end) = 0;

-Herbert

Subject: How to Null an array

From: Wds

Date: 3 Dec, 2002 17:59:39

Message: 4 of 12


A(N:end)=0
try it!!!

wds

"dderijken" <dderijken@hotmail.com>
??????:bklouuce2anc4necmc36s6o05kn6ptlqn3@4ax.com...
> Hi,
>
> I have an array for example:
>
> A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
>
> How can make N last numbers to be zero like this :
> for example N=5
>
> A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
>
> Thanks
>

Subject: How to Null an array

From: Jox

Date: 3 Dec, 2002 07:22:31

Message: 5 of 12

Herbert Ramoser wrote:
>
>
> Matt Wolinsky wrote:
>> dderijken wrote:
>>
>>>
>>>Hi,
>>>
>>>I have an array for example:
>>>
>>>A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
>>>
>>>How can make N last numbers to be zero like this :
>>>for example N=5
>>>
>>>A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
>>>
>>>Thanks
>>>
>>>
>>
>>
>>
>> A(end-N:end)=0;
>
> You are close:
> A(end-N+1:end) = 0;
>
> -Herbert
>
>


Just to be shure that 'end-N+1' is never negative:
A(max(end-N+1,1):end) = 0;


-Joerg

Subject: How to Null an array

From: Brett Shoelson

Date: 3 Dec, 2002 09:45:40

Message: 6 of 12


"Wds" <wds76218@sohu.com> wrote in message
news:ashvek$2p6c$1@mail.cn99.com...
>
> A(N:end)=0
> try it!!!
>
> wds
>
> "dderijken" <dderijken@hotmail.com>
> ??????:bklouuce2anc4necmc36s6o05kn6ptlqn3@4ax.com...
> > Hi,
> >
> > I have an array for example:
> >
> > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
> >
> > How can make N last numbers to be zero like this :
> > for example N=5
> >
> > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
> >
> > Thanks
> >
>
>

Perhaps YOU should try it, WDS.
Brett

Subject: How to Null an array

From: Wds

Date: 4 Dec, 2002 10:21:26

Message: 7 of 12

I had tried it,and it was right!!!
"A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8];
A(16:20)=0;"
YOU try
IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Do you think what wrong was?
Maybe I didn't understand you more accuratly or speak more clearly .
I was zealous to help you as possible as I could, but you made me angry,and
I was very disappointed !!!



"Brett Shoelson" <shoelson@helix.nih.gov> дÈëÏûÏ¢ÐÂÎÅ
:9t3H9.5$56.4452@mencken.net.nih.gov...
>
> "Wds" <wds76218@sohu.com> wrote in message
> news:ashvek$2p6c$1@mail.cn99.com...
> >
> > A(N:end)=0
> > try it!!!
> >
> > wds
> >
> > "dderijken" <dderijken@hotmail.com>
> > ??????:bklouuce2anc4necmc36s6o05kn6ptlqn3@4ax.com...
> > > Hi,
> > >
> > > I have an array for example:
> > >
> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
> > >
> > > How can make N last numbers to be zero like this :
> > > for example N=5
> > >
> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
> > >
> > > Thanks
> > >
> >
> >
>
> Perhaps YOU should try it, WDS.
> Brett
>
>

Subject: How to Null an array

From: Wds

Date: 4 Dec, 2002 10:23:00

Message: 8 of 12

I had tried it,and it was right!!!
"A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8];
A(16:20)=0;"
YOU try
IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Do you think what wrong was?
Maybe I didn't understand you more accuratly or speak more clearly .
I was zealous to help you as possible as I could, but you made me angry,and
I was very disappointed !!!




"Brett Shoelson" <shoelson@helix.nih.gov> дÈëÏûÏ¢ÐÂÎÅ
:9t3H9.5$56.4452@mencken.net.nih.gov...
>
> "Wds" <wds76218@sohu.com> wrote in message
> news:ashvek$2p6c$1@mail.cn99.com...
> >
> > A(N:end)=0
> > try it!!!
> >
> > wds
> >
> > "dderijken" <dderijken@hotmail.com>
> > ??????:bklouuce2anc4necmc36s6o05kn6ptlqn3@4ax.com...
> > > Hi,
> > >
> > > I have an array for example:
> > >
> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
> > >
> > > How can make N last numbers to be zero like this :
> > > for example N=5
> > >
> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
> > >
> > > Thanks
> > >
> >
> >
>
> Perhaps YOU should try it, WDS.
> Brett
>
>

Subject: How to Null an array

From: Dan Hensley

Date: 4 Dec, 2002 04:06:38

Message: 9 of 12

On Wed, 04 Dec 2002 10:23:00 +0800, Wds wrote:

> I had tried it,and it was right!!!
> "A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8];
> A(16:20)=0;"
> YOU try
>
IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


Brett is right. What you originally posted was not correct. For this
case, N=5. You said

A(N:end)=0

which is A(5:end)=0. This is not A(16:20)=0.

What you meant to say is

A(end-N+1:end)=0

Dan


>
> Do you think what wrong was?
> Maybe I didn't understand you more accuratly or speak more clearly .
> I was zealous to help you as possible as I could, but you made me angry,and
> I was very disappointed !!!
>
>
>
>
> "Brett Shoelson" <shoelson@helix.nih.gov> дÈëÏûÏ¢ÐÂÎÅ
> :9t3H9.5$56.4452@mencken.net.nih.gov...
>>
>> "Wds" <wds76218@sohu.com> wrote in message
>> news:ashvek$2p6c$1@mail.cn99.com...
>> >
>> > A(N:end)=0
>> > try it!!!
>> >
>> > wds
>> >
>> > "dderijken" <dderijken@hotmail.com>
>> > ??????:bklouuce2anc4necmc36s6o05kn6ptlqn3@4ax.com...
>> > > Hi,
>> > >
>> > > I have an array for example:
>> > >
>> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
>> > >
>> > > How can make N last numbers to be zero like this :
>> > > for example N=5
>> > >
>> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
>> > >
>> > > Thanks
>> > >
>> >
>> >
>>
>> Perhaps YOU should try it, WDS.
>> Brett
>>
>>

Subject: How to Null an array

From: Wds

Date: 4 Dec, 2002 12:09:57

Message: 10 of 12

I didn't express me clearly!!!!!
wds

"Dan Hensley" <danDOThensley@attbi.com>
??????:pan.2002.12.04.04.06.14.740816@attbi.com...
> On Wed, 04 Dec 2002 10:23:00 +0800, Wds wrote:
>
> > I had tried it,and it was right!!!
> > "A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8];
> > A(16:20)=0;"
> > YOU try
> >
> IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>
>
> Brett is right. What you originally posted was not correct. For this
> case, N=5. You said
>
> A(N:end)=0
>
> which is A(5:end)=0. This is not A(16:20)=0.
>
> What you meant to say is
>
> A(end-N+1:end)=0
>
> Dan
>
>
> >
> > Do you think what wrong was?
> > Maybe I didn't understand you more accuratly or speak more clearly .
> > I was zealous to help you as possible as I could, but you made me
angry,and
> > I was very disappointed !!!
> >
> >
> >
> >
> > "Brett Shoelson" <shoelson@helix.nih.gov> дÈëÏûÏ¢ÐÂÎÅ
> > :9t3H9.5$56.4452@mencken.net.nih.gov...
> >>
> >> "Wds" <wds76218@sohu.com> wrote in message
> >> news:ashvek$2p6c$1@mail.cn99.com...
> >> >
> >> > A(N:end)=0
> >> > try it!!!
> >> >
> >> > wds
> >> >
> >> > "dderijken" <dderijken@hotmail.com>
> >> > ??????:bklouuce2anc4necmc36s6o05kn6ptlqn3@4ax.com...
> >> > > Hi,
> >> > >
> >> > > I have an array for example:
> >> > >
> >> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
> >> > >
> >> > > How can make N last numbers to be zero like this :
> >> > > for example N=5
> >> > >
> >> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
> >> > >
> >> > > Thanks
> >> > >
> >> >
> >> >
> >>
> >> Perhaps YOU should try it, WDS.
> >> Brett
> >>
> >>
>

Subject: How to Null an array

From: Brett Shoelson

Date: 5 Dec, 2002 10:32:16

Message: 11 of 12


"Wds" <wds76218@sohu.com> wrote in message
news:asjvar$1cvl$1@mail.cn99.com...
> I didn't express me clearly!!!!!
> wds
>
> "Dan Hensley" <danDOThensley@attbi.com>
> ??????:pan.2002.12.04.04.06.14.740816@attbi.com...
> > On Wed, 04 Dec 2002 10:23:00 +0800, Wds wrote:
> >
> > > I had tried it,and it was right!!!
> > > "A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8];
> > > A(16:20)=0;"
> > > YOU try
> > >
> >
IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> >
> >
> > Brett is right. What you originally posted was not correct. For this
> > case, N=5. You said
> >
> > A(N:end)=0
> >
> > which is A(5:end)=0. This is not A(16:20)=0.
> >
> > What you meant to say is
> >
> > A(end-N+1:end)=0
> >
> > Dan
> >
> >
> > >
> > > Do you think what wrong was?
> > > Maybe I didn't understand you more accuratly or speak more clearly .
> > > I was zealous to help you as possible as I could, but you made me
> angry,and
> > > I was very disappointed !!!
> > >
> > >
> > >
> > >
> > > "Brett Shoelson" <shoelson@helix.nih.gov> дÈëÏûÏ¢ÐÂÎÅ
> > > :9t3H9.5$56.4452@mencken.net.nih.gov...
> > >>
> > >> "Wds" <wds76218@sohu.com> wrote in message
> > >> news:ashvek$2p6c$1@mail.cn99.com...
> > >> >
> > >> > A(N:end)=0
> > >> > try it!!!
> > >> >
> > >> > wds
> > >> >
> > >> > "dderijken" <dderijken@hotmail.com>
> > >> > ??????:bklouuce2anc4necmc36s6o05kn6ptlqn3@4ax.com...
> > >> > > Hi,
> > >> > >
> > >> > > I have an array for example:
> > >> > >
> > >> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 3 4 5 7 8]
> > >> > >
> > >> > > How can make N last numbers to be zero like this :
> > >> > > for example N=5
> > >> > >
> > >> > > A=[1 2 3 4 5 6 4 5 6 3 4 5 6 2 2 0 0 0 0 0]
> > >> > >
> > >> > > Thanks
> > >> > >
> > >> >
> > >> >
> > >>
> > >> Perhaps YOU should try it, WDS.
> > >> Brett
> > >>
> > >>
> >
>
>

I apologize if I upset you. I've given (and received) advice on this
newsgroup for a long time; sometimes I make mistakes and post replies
without thinking them through. In any event, a bit of levity is called for.
Lighten up!
Brett

Subject: How to Null an array

From: dderijken

Date: 9 Dec, 2002 16:30:54

Message: 12 of 12

Thank you so much buddies,
Matt Wolinsky , Herbert Ramoser ...
Have a nice day

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