필터 지우기
필터 지우기

non-uniform symmetric grid in 1D

조회 수: 31 (최근 30일)
abolfazl mahmoodpoor
abolfazl mahmoodpoor 2022년 11월 2일
댓글: abolfazl mahmoodpoor 2022년 11월 2일
I am trying to make a non-uniform symmetric grid in 1D (dense grid close to the boundaries), is there any simple command?

채택된 답변

Bruno Luong
Bruno Luong 2022년 11월 2일
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
abolfazl mahmoodpoor
abolfazl mahmoodpoor 2022년 11월 2일
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

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2022년 11월 2일
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
abolfazl mahmoodpoor
abolfazl mahmoodpoor 2022년 11월 2일
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.

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by