필터 지우기
필터 지우기

From linear to logarithmic distribution

조회 수: 1 (최근 30일)
Mohamed Abdalmoaty
Mohamed Abdalmoaty 2015년 6월 9일
댓글: Walter Roberson 2015년 6월 10일
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?

답변 (1개)

Walter Roberson
Walter Roberson 2015년 6월 9일
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
Mohamed Abdalmoaty
Mohamed Abdalmoaty 2015년 6월 9일
편집: Walter Roberson 2015년 6월 10일
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 2015년 6월 10일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by