how to creat a 3-by-3 node stcuture(having coordinate of each node) in class?

 채택된 답변

HighPhi
HighPhi 2020년 8월 4일

0 개 추천

I'd say,
classdef yourNodes
properties
S; % start nodes
T; % end nodes
pts; % points
end
methods
function obj = addNode(obj, X, Y, Z)
obj.pts = [obj.pts; X, Y, Z];
end
function obj = connectNodes(obj, ind1, ind2)
obj.S = [obj.S, ind1];
obj.T = [obj.T, ind2];
end
end
end
Then you could simply...
myNodes = yourNodes;
myNodes = addNode(myNodes, 1, 1, 1); % add node 1
myNodes = addNode(myNodes, 2, 2, 2); % add node 2
myNodes = connectNodes(myNodes, 1, 2); % Connect node1 to node2

댓글 수: 1

JAMMI ASHOK
JAMMI ASHOK 2020년 9월 24일
Hey Highphi.
It's nice the way you have done it ! Where have you learnt OOP 's in MATLAB. I've been searching a lot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2019a

태그

질문:

2020년 8월 4일

댓글:

2020년 9월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by