How to generate Q4 element mesh in selected area?

3 ビュー (過去 30 日間)
waqas
waqas 2021 年 9 月 8 日
回答済み: darova 2021 年 9 月 8 日
Hi,
I have a region ( variable 'nmask' in the .MAT file) on which I want to generate a Q4 mesh. In my current implementation, the nodes are not falling perfectly on the boundary of the region. Figure below should explain it further where red markers show the location of the nodes. Following code was used to generate these:
%load(data.mat)
tx = mfc:subset:mlc;
ty = mfr:subset:mlr;
[TX,TY] = meshgrid(tx,ty);
nodeDetails = [(1:size(TX,1)*size(TX,2))', TY(:),TX(:)];
%Connectivity Matrix
c = 0;
conect = zeros((size(TX,1)-1)*(size(TX,2)-1),4);
for j = 0:(size(TX,2)-2)
for i = 1: size(TX,1)-1
c = c + 1;
ii = j*(size(TX,1)) + i;
conect(c,:) = [ii, ii + 1, ii + size(TX,1) + 1, ii + size(TX,1)];
end
end
I am only interested in the white region. How can I also discard the other points?

採用された回答

darova
darova 2021 年 9 月 8 日
What about this?
x = [-10:-8 -7:7 8:10];
y = [-8:-6 -5:5 6:8];
[X,Y] = meshgrid(x,y);
i1 = -8<X & X<8 & -6<Y & Y<6; % inside region
i2 = X<0 & abs(Y)<2; % small hole right side
ind = i1 | i2;
Z = X*0;
Z(ind) = nan; % remove inside part
plot(X(:),Y(:),'.r') % whole mesh
surface(X,Y,Z)
view(45,45)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by