Clear Filters
Clear Filters

Create a matrix of element (points) connectivity

7 views (last 30 days)
sci hub
sci hub on 5 Jul 2021
Edited: sci hub on 6 Jul 2021
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]

Answers (1)

Yongjian Feng
Yongjian Feng on 5 Jul 2021
Can you just change
m=3;
n=3;
for 9 ponts?
  1 Comment
sci hub
sci hub on 5 Jul 2021
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 ??

Sign in to comment.

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!