Effacer les filtres
Effacer les filtres

Create a matrix of element (lines) points connectivity

6 vues (au cours des 30 derniers jours)
sci hub
sci hub le 1 Juil 2021
Commenté : sci hub le 1 Juil 2021
Hi,
I am new to matlab trying to create a matrix as attached in the code below
clear all;
clc
nelments = 3;
nelments_vec = 1:nelments;
npoint = 5;
connect = zeros(nelments,npoint); % INTIALIZE ELEMENT CONNECTIVITY
for i=1:nelments
for j=1:npoint
connect(i,j)=[nelments_vec(i) nelments_vec(i)+1]; % ELEMENT/pointCONNECTIVITY MATRIX I WOULD LIKE TO OBTAIN
end
end
The answer should be
connect =[1 2 3 4 5;
5 6 7 8 9;
9 10 11 12 13]
How could I obtain such matrix with different values of npoint and nelments ???
I wish anyone could help me !!!!

Réponse acceptée

Matt J
Matt J le 1 Juil 2021
Modifié(e) : Matt J le 1 Juil 2021
nelments = 3;
npoint = 5;
connect=(1:npoint) + (npoint-1)*(0:nelments-1).'
connect = 3×5
1 2 3 4 5 5 6 7 8 9 9 10 11 12 13
  1 commentaire
sci hub
sci hub le 1 Juil 2021
@Matt J seems great, can i draw such line with nodes ??

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by