geting started with oop
Show older comments
hi everybody, i got a probally simple question but would be gratefull if anyone could help
i got the following code (that does not work)
classdef Knot
properties
x
y
end % properties
methods
function K = Knot(x,y)
K.x=x;
K.y=y;
end%functions
end%methods
end %class
classdef Slab<Knot
properties
Material
StartKnot
EndKnoten
end%properties
methods
function S = Slab(StartKnot,EndKnot)
S.StartKnot = StartKnot;
S.EndKnot = EndKnot;
end%function
end%methods
end%class
in my mind the subclass Slab should get the properties x and y.
trying to run it gives me this:
>> k1 = Knoten(1,1);
>> k2 = Knoten(2,2);
>> s= Stab(k1)
??? Input argument "x" is undefined.
Error in ==> Knoten>Knoten.Knoten at 8
K.x=x;
Error in ==> Stab>Stab.Stab at 8
function S = Stab(StartKnoten)
acctually i wanted to get a Slab class that has the properties of Knot and could be acceses like this:
k=Knot(1,1);kk = Knot(1,2);S = Slab(k1,k2);
Slab.StartKnot.x should deliver the x propertie of Knot
obviously i got something wrong
thankfull for help
Accepted Answer
More Answers (0)
Categories
Find more on Neuroimaging in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!