Reputation: 1
I've a issue with matlab constructors when I try to instantiate an array of classes.
I get the following error:
??? The following error occurred converting from volta to double:
Error using ==> double
Conversion to double from volta is not possible.
Error in ==> circuito>circuito.iniciarNovaVolta at 37
Circuito.Voltas(Circuito.Nvoltas) = Volta(Nmaxpiloto);
Error in ==> testes at 99
c1.iniciarNovaVolta(10);
And my code is:
function iniciarNovaVolta(Circuito, Nmaxpiloto)
Circuito.Voltas(Circuito.Nvoltas) = Volta(Nmaxpiloto);
Circuito.Nvoltas = Circuito.Nvoltas + 1;
end
The contructor at Volta class is:
function Volta=volta(Nmaxpiloto)
if(nargin>0)
%Volta.Melhortempovolta=Melhortempovolta;
Volta.Nmaxpiloto=Nmaxpiloto;
end
end
I had this issue more than once, but the types looks right. Could you tell me what I can't see ?
function Volta=volta(Nmaxpiloto)
if(nargin>0)
Upvotes: 0
Views: 262
Reputation: 1
The contructor at Volta class is:
function Volta=volta(Nmaxpiloto)
if(nargin>0)
%Volta.Melhortempovolta=Melhortempovolta;
Volta.Nmaxpiloto=Nmaxpiloto;
end
end
I had this issue more than once, but the types looks right. Could you tell me what I can't see ?
function Volta=volta(Nmaxpiloto)
if(nargin>0)
Upvotes: 0
Reputation: 4477
Check your types. I'm guessing that Volta(Nmaxpiloto)
is of type double and Circuito.Voltas(Circuito.Nvoltas)
is of type volta. This can't be done. Sounds like you are mixing a lot of OOP with MATLAB, which is not to say that you can't. You might want to look at this link: http://www.mathworks.com/help/techdoc/matlab_prog/f2-47534.html#bqt_gwr to see the valid MATLAB classes.
Upvotes: 1