Filter löschen
Filter löschen

non-uniform symmetric grid in 1D

31 Ansichten (letzte 30 Tage)
abolfazl mahmoodpoor
abolfazl mahmoodpoor am 2 Nov. 2022
I am trying to make a non-uniform symmetric grid in 1D (dense grid close to the boundaries), is there any simple command?

Akzeptierte Antwort

Bruno Luong
Bruno Luong am 2 Nov. 2022
The chebychev nodes cross my mind
leftbnd=-10
leftbnd = -10
rightbnd = 10;
n = 30
n = 30
chebychevgrid=@(leftbnd,rightbnd,n)leftbnd+((rightbnd-leftbnd)/2)*(cos(linspace(pi,0,n))+1)
chebychevgrid = function_handle with value:
@(leftbnd,rightbnd,n)leftbnd+((rightbnd-leftbnd)/2)*(cos(linspace(pi,0,n))+1)
a = chebychevgrid(leftbnd,rightbnd,n)
a = 1×30
-10.0000 -9.9414 -9.7662 -9.4765 -9.0758 -8.5686 -7.9609 -7.2600 -6.4739 -5.6119 -4.6841 -3.7014 -2.6753 -1.6178 -0.5414 0.5414 1.6178 2.6753 3.7014 4.6841 5.6119 6.4739 7.2600 7.9609 8.5686 9.0758 9.4765 9.7662 9.9414 10.0000
plot(a, ones(size(a)),'-o')
  1 Kommentar
abolfazl mahmoodpoor
abolfazl mahmoodpoor am 2 Nov. 2022
Thanks Bruno for your kind answer.
I also found this, by changing sigma it is possible to control mesh density close to the boundaries.
N = 50;
d = 1;
sigma = d/30;
x50 = d/2;
x = d./(1+exp(-(linspace(0,d,N)-x50)/sigma));
plot(x,0,'bo')
grid on

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 2 Nov. 2022
No, there is no simple command for it.
If you have the first half, say a row vector B, then you can build the rest as
[B, ENDVALUE-fliplr(B)]
except, that is, for the case where the last B value is exactly half-way through, in which case you do not want to duplicate that value...
You can create your own simple functions for this, but Mathworks does not provide any simple command for it.
  1 Kommentar
abolfazl mahmoodpoor
abolfazl mahmoodpoor am 2 Nov. 2022
Walter thanks for your kind answer,
I think I didnot asked my question correctly,
My question is following: We know that x = linspace(0,1,N) created a uniform mesh from 0 to 1 with N-1 interval in a way that \deltax = (1-0)/(N-1). So \deltax is constant everywhere, I need to have small \deltax close to the 0 and 1, but the total number of N should be the same, and when move from 0 to 0.5 or from 1 to the 0.5 \deltax should increse gardually.
I hope I could explaine it clear.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by