Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How can i acess to created objects out of the class
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello. I have a simple Class:
classdef Packung
properties
preis
menge
l
end
methods
function this = Packung(p,m,l)
this.preis = 0;
this.menge = 0;
this.l=l;
%this = this.setPreisMenge(p,m);
end
function this = setPreisEinkaufswagen(this, p)
xxx = this.preis;
display(xxx);
% Objekt2 = setPreisMenge(Objekt2, 2, p);
end
function [this,objekt] = setPreisMenge(this,objekt, p,m)
this.preis = p;
this.menge = m;
objekt.preis = objekt.preis + 100;
end
end
end
now i have another function, in which i want to make a for loop, going through all the objects created from my Class Packung. How to do this?
I tired following: Function PriceProducts is NOT in the Class. Before i started the Function, i made a object from the class: Milch = Packung (1,2,3)
function PriceProducts()
for i=1:10
Product_buying= Milch;
...
end
Though i get an error, Undefined function or variable 'Milch'.
How to manage this? I'd like to predifine all the Objects that need to be used, and then i want to loop them.
댓글 수: 0
답변 (2개)
Erik S.
2015년 2월 8일
Don't you have to pass the "Milch" variable to the function PriceProducts? I don't see how the function gets this value otherwise?
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!