0

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)
1
  • 1
    Can you show more code? It would be nice to see the call to the function as well as the function you are trying to call. Commented Jan 11, 2012 at 23:11

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi again! 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)
0

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.