Create a matrix of element (points) connectivity

7 次查看(过去 30 天)
Hiii
I am new to matlab, trying to create a 2D rectangular boxs with number of points as attached, with number of rectangular boxes
I also attached the code (it's only with 4 points) I would like to know how to make it with 9 points... or 16 points ?
clear all;
clc;
m=2; % m : number of points in x direction in each rectangular box
n=2; % n : number of points in y direction in each rectangular box
% Numbering
nel = m*n; % total number of elements (total number of rectangular box
elem = zeros(nel,9); % matrix of element connectivities
for I = 1:m
for J = 1:n
elem_num = J + (I-1)*n; % element counter
elem(elem_num,1) = J + (I-1)*(n+1); % node 1 % SHOULD ADD UNTIL NODE 9
elem(elem_num,2) = elem(elem_num,1) + (n+1); % node 2
elem(elem_num,3) = elem(elem_num,2) + 1; % node 3
elem(elem_num,4) = elem(elem_num,1) + 1; % node 4
% elem(elem_num,5) =; % node 5
%elem(elem_num,6) = ; % node 6
% elem(elem_num,7) = ; % node 7
% elem(elem_num,8) = ; % node 8
% elem(elem_num,9) = ; % node 9
end
end
% I would like to obtain elem =[1 3 4 2 5 6 7 8 9;3 10 11 4 12 13 14 6 15]

回答(1 个)

Yongjian Feng
Yongjian Feng 2021-7-5
Can you just change
m=3;
n=3;
for 9 ponts?
  1 个评论
sci hub
sci hub 2021-7-5
Thank you for your reply. But I did not mean that..
m and n are the elements number
not the points.. as attached
I would like to obtain elem =[1 3 4 2 5 6 7 8 9;3 10 11 4 12 13 14 6 15]
Hope you get what I meant ??

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by