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:
Uneven grid points?

Subject: Uneven grid points?

From: Shashank

Date: 8 Oct, 2012 07:27:07

Message: 1 of 3

How to create a variable (using linspace) for the following configuration:

Distance between the first and second point = 0.5h
Distance between the second and third point = h
Distance between the third and fourth point = h
And so on...
Distance between the (N-2)th and (N-1)th point = h
Distance between the (N-1)th and Nth point = 0.5h

A quick retort would be appreciated.

Subject: Uneven grid points?

From: Bjorn Gustavsson

Date: 8 Oct, 2012 10:55:08

Message: 2 of 3

"Shashank " <shashank312@yahoo.co.uk> wrote in message <k4tv8b$kbp$1@newscl01ah.mathworks.com>...
> How to create a variable (using linspace) for the following configuration:
>
> Distance between the first and second point = 0.5h
> Distance between the second and third point = h
> Distance between the third and fourth point = h
> And so on...
> Distance between the (N-2)th and (N-1)th point = h
> Distance between the (N-1)th and Nth point = 0.5h
>
> A quick retort would be appreciated.
>
X = cumsum([0,0.5,ones(1,nX-3), 0.5])*h;

HTH

Subject: Uneven grid points?

From: Bruno Luong

Date: 8 Oct, 2012 11:13:08

Message: 3 of 3

Trivial counting:

h = 0.1
N = 10;
x0 = 3;

x = x0 + [0 linspace(0.5,N-2.5,N-2) N-2]*h

Bruno

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