how to fix "Undefined variable "P2" or class "P2.TilknytMedarbejder""?
Mostrar comentarios más antiguos
I am working on a university projekt, that is giving me some issues.
I am trying to creat a Matrix that i can change the values in. I have managede to get a Matrix started that looks like this:
ans =
0 1 2 3 4 5 6
1 0 0 0 0 0 0
2 0 0 0 0 0 0
3 0 0 0 0 0 0
4 0 0 0 0 0 0
It is created through a class constructor (i will copy the whole script file in here later)
I then have to make a function that will change the 0 in (2,2) to a 2
so i have made this script file with the function tilknytmedarbejder (i am a dane so some of the variable and function names are in danish)
classdef Projekt2 <handle properties Projekter
end
methods (Access=public)
function P2=Projekt2 (antalprojekter,antalmedarbejdere)
P2.Projekter=zeros(antalprojekter+1,antalmedarbejdere+1);
P2.Projekter(1,:)=0:6;
P2.Projekter(:,1)=0:4;
end
function TilknytMedarbejder (P2,Projekt,Medarbejder)
P2.Projekter(Projekt+1,Medarbejder+1)=2;
end
end
end
When i try to call the function TilknytMedarbejder by writing in the command windue P2.TilknytMedarbejder(1,1) (because i have it adding one to both of the variables) i get the error message: "Undefined variable "P2" or class "P2.TilknytMedarbejder""?
is there a simple solution to this???
please help me since i am no expert but eager to learn
best regards
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Construct and Work with Object Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!