Create logarithmically spaced vector with points spaced more closely at far end of vector

조회 수: 39 (최근 30일)
Is it possible to use logspace (or some other approach) to create a logrithmically spaced vector where the points are more closely spaced at the far end of the vector? For example, for the vector x = logspace(1, 2, 100), I would like to have the points spaced more closely toward the 10^2 = 100 end of the vector. I can't be the first person to want to do this...Thanks in advance for anyone's help!

채택된 답변

Akira Agata
Akira Agata 2022년 11월 18일
Like this?
% Normal log-spaced vector
x1 = logspace(1, 2, 10);
% Create inverse log space
delta = diff(x1);
delta = fliplr(delta);
% Inversely log-spaced vector
x2 = [10, 10+cumsum(delta)];
% Check!
figure
plot(x1, 'o')
hold on
plot(x2, 'v')
legend({'x1', 'x2'}, 'Location', 'best')
  댓글 수: 3
Akira Agata
Akira Agata 2022년 11월 19일
Thank you for your comment. Unfortunately, it's not clear for me what the expected result looks like. Could you give us a small example?
Eric Roden
Eric Roden 2022년 11월 19일
Actually, your solution worked fine for what I needed. Many thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by