Azzera filtri
Azzera filtri

Create a matrix of element (lines) points connectivity

6 visualizzazioni (ultimi 30 giorni)
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 !!!!

Risposta accettata

Matt J
Matt J il 1 Lug 2021
Modificato: Matt J il 1 Lug 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

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by