use object for interative loop
Mostrar comentarios más antiguos
Hi, I have an object that I want to iterate through it's members with a while loop but I can't see how to call the while loop? Thanks, tom
classdef cls_myobj
properties
members = {'abc' 'bbc' 'cbc'}
length = 3
index = 0
end
methods
function [this,obj] = getNext(this)
this.index = this.index +1;
if this.index > this.length
obj = -1; %or false???
else
obj = this.members(this.index);
end
end
end
myobj=cls_myobj;
while [this, x] = getNext(myobj)
%do stuff
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Algorithm Design Basics en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!