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:
Creating an array!

Subject: Creating an array!

From: ronarld.chan@googlemail.com

Date: 28 Jun, 2009 15:05:27

Message: 1 of 4

Hey guys, what is the quickest way to create an array without using a
for loop. The pattern of the array is as follows:

0, 0.25, 0.75, 1.45, 2.45, ...... the distance between one point to
its sucessive one is i*c, where c is constant and i is an index.
Thanks!

Ron

Subject: Creating an array!

From: dpb

Date: 28 Jun, 2009 15:18:07

Message: 2 of 4

ronarld.chan@googlemail.com wrote:
> Hey guys, what is the quickest way to create an array without using a
> for loop. The pattern of the array is as follows:
>
> 0, 0.25, 0.75, 1.45, 2.45, ...... the distance between one point to
> its sucessive one is i*c, where c is constant and i is an index.

"the distance between one point to its sucessive one is i*c, where c is
constant and i is an index."

Well, not for the example...

0.75/0.25 --> c = 3
1.45/0.75 --> c = 1.9333...
2.45/1.45 --> c = 1.68966...

Think you need a better defining function...

Once you can write that, the answer to the original question is probably
trivial. :)

--

Subject: Creating an array!

From: John D'Errico

Date: 28 Jun, 2009 15:30:03

Message: 3 of 4

"ronarld.chan@googlemail.com" <ronarld.chan@googlemail.com> wrote in message <bfdc6a6a-6764-440d-b796-0af2daab0819@a36g2000yqc.googlegroups.com>...
> Hey guys, what is the quickest way to create an array without using a
> for loop. The pattern of the array is as follows:
>
> 0, 0.25, 0.75, 1.45, 2.45, ...... the distance between one point to
> its sucessive one is i*c, where c is constant and i is an index.

This is a good description, but it does not match
your example.

0.25*cumsum(0:4)

John

Subject: Creating an array!

From: Faraz Afzal

Date: 28 Jun, 2009 15:50:02

Message: 4 of 4

I would suggest a better explanation really...

More the problem is well defined trivial the solution becomes..

if ur constant 'c' is really a constant... or it is changing through some function.. i mean is that a variable..is it a common ratio or what,???

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <h2829r$gij$1@fred.mathworks.com>...
> "ronarld.chan@googlemail.com" <ronarld.chan@googlemail.com> wrote in message <bfdc6a6a-6764-440d-b796-0af2daab0819@a36g2000yqc.googlegroups.com>...
> > Hey guys, what is the quickest way to create an array without using a
> > for loop. The pattern of the array is as follows:
> >
> > 0, 0.25, 0.75, 1.45, 2.45, ...... the distance between one point to
> > its sucessive one is i*c, where c is constant and i is an index.
>
> This is a good description, but it does not match
> your example.
>
> 0.25*cumsum(0:4)
>
> John

Tags for 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