필터 지우기
필터 지우기

Create a matrix of element (lines) points connectivity

조회 수: 6 (최근 30일)
sci hub
sci hub 2021년 7월 1일
댓글: sci hub 2021년 7월 1일
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 !!!!

채택된 답변

Matt J
Matt J 2021년 7월 1일
편집: Matt J 2021년 7월 1일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by