Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How can i acess to created objects out of the class
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Erik S.
am 8 Feb. 2015
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 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!