Borrar filtros
Borrar filtros

node creation using class

3 visualizaciones (últimos 30 días)
Shahrukh s
Shahrukh s el 4 de Ag. de 2020
Comentada: JAMMI ASHOK el 24 de Sept. de 2020
how to creat a 3-by-3 node stcuture(having coordinate of each node) in class?

Respuesta aceptada

Highphi
Highphi el 4 de Ag. de 2020
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 comentario
JAMMI ASHOK
JAMMI ASHOK el 24 de Sept. de 2020
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Construct and Work with Object Arrays en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by