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:
logspace

Subject: logspace

From: Hermano Cappa

Date: 6 Jan, 2011 13:49:07

Message: 1 of 2

Hi,

How can you generate a logspaced vector but with the fine spacing of your vector at the end instead of at the begin?

example:
logspace(0.1,1,5)

result:
1.2589 2.1135 3.5481 5.9566 10.0000

The spacing between the first and second number is small and increases to the fifth number. But I want the opposite: A great spacing between the first and second number and finer to the fifth number.

Any suggestions?

Subject: logspace

From: Walter Roberson

Date: 7 Jan, 2011 07:36:00

Message: 2 of 2

On 06/01/11 7:49 AM, Hermano Cappa wrote:

> How can you generate a logspaced vector but with the fine spacing of
> your vector at the end instead of at the begin?
>
> example:
> logspace(0.1,1,5)
>
> result:
> 1.2589 2.1135 3.5481 5.9566 10.0000
>
> The spacing between the first and second number is small and increases
> to the fifth number. But I want the opposite: A great spacing between
> the first and second number and finer to the fifth number.

There are multiple ways of doing that, of course. You won't be able to
do it as a pure geometric progression. Here's a version that does it as
a geometric progression on the differences:

rlogspace = @(a,b,n) 10^b+1-(10^b+1-10^a).^((n-1:-1:0)./(n-1));

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