Reverse geometric progression algorithm
Show older comments
I would like to have a set of points from -b to b using a geometric progression from dpB / 2 to b and mirroring the points with respect to 0. However, I want the grid to be "denser" closer to b, meaning that the gap between 2 points going from dpB/2 to b should decrease not increase. How can I tweek my code to achieve that?
b = 5;
N = 25;
dpB = 2 * b / N;
kk = (N+1)/2;
r = ((dpB/2)/b)^(1 / (kk-1));
pBy = zeros(1,N+1);
mid = (N+1) / 2;
pBy(N+1) = b;
pBy(1) = -b;
for i=N:-1:(mid+1)
pBy(i) = pBy(i+1) * r;
end
pBy(1:mid) = -flip(pBy((mid+1):end));
Accepted Answer
More Answers (0)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!