Borrar filtros
Borrar filtros

From linear to logarithmic distribution

5 visualizaciones (últimos 30 días)
Mohamed Abdalmoaty
Mohamed Abdalmoaty el 9 de Jun. de 2015
Comentada: Walter Roberson el 10 de Jun. de 2015
Given a linear frequency scale denoted by the vector f = 1:fmax; fmax is known, say 1000.
How can I construct, out of this vector, a logarithmic selection of the entries such that the ratio between two consecutive odd numbers is 1.1?

Respuestas (1)

Walter Roberson
Walter Roberson el 9 de Jun. de 2015
You cannot. The only solution to x*11/10 = x+2 is x = 20, and that is an even number.
If the task is to construct a vector of length fmax such that the ratio
x(2*k+3)/x(2*k+1)
is 11/10 for k in nonnegative integers, then as logarithmic progression is x(n+1) = C * x(n) for some constant C, it follows that x(n+2) = C*(C*x(n)) = C^2 * x(n). You want that value, C^2 to be 1.1, so your C is sqrt(1.1). Then you get
initial_value * sqrt(1.1).^(0:fmax-1)
  2 comentarios
Mohamed Abdalmoaty
Mohamed Abdalmoaty el 9 de Jun. de 2015
Editada: Walter Roberson el 10 de Jun. de 2015
fmax = 1000; Ratio = 1.1;
Lines_linear = 1:fmax/2;
currentIdx = 1; selected = 1;
Lines = 1;
while currentIdx < fmax/2
[~,nextIdx]=min(abs(Lines_linear(currentIdx)*Ratio-...
Lines(currentIdx+1:length(Lines_linear))));
currentIdx = nextIdx+currentIdx;
% a logarithmic step!
if Lines_linear(currentIdx) > sqrt(Ratio)*Lines(length(Lines)),
selected = [selected;currentIdx];
Lines = [ Lines; Lines_linear(currentIdx)];
end
end
Walter Roberson
Walter Roberson el 10 de Jun. de 2015
I have no idea what that code is intended to do. It is uncommented and the relationship to the Question you posted is not obvious.
You start with Lines=1 which is length 1. In the first statement in your while you try to index Lines from 2 to length(Lines_linear) which would be 2:500. But Lines only has 1 entry, so you cannot access elements 2 to 500 of it.

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by