Matlab-Error-Variable might be used before it is defined

63 Views Asked by At

enter image description hereI have defined some classes and two of them Called "Global" &"GlobalFlag". All the classes are in one folder and same path. But in another related class I got this warning "Variable might be used before it is defined" and also after running the main code I get the error "Global is not found in the current folder or on the MATLAB path, but exists in:..."

Everything looks correct and all the classes and main code are in a same folder.

How can I fix this problem?

In this screenshot "Die" is also an object of a class.

Everything looks correct and all the classes and main code are in a same folder and same path. The classes "Global" and "GlobalFlag" don't have any warnings.

Main code:

   Optimization = Optimization.CalcOptimization(Die,Machine,Alloy,Billet);

Error:

 'Global' is not found in the current folder or on the MATLAB path, but exists in: ...

  Change the MATLAB current folder or add its folder to the MATLAB path.

  Error in CProfilOptimization/CalcOptimization (line 19)
        Die.SpeedMaxOpt = Global.SpeedMaxOpt;

  Error in main2 (line 153)
  Optimization=
  Optimization.CalcOptimization(Die,Machine,Alloy,Billet);

Class CalcOptimization:

 function [obj] = CalcOptimization(obj, Die, Machine, Alloy, Billet)

        error = false;  

        Die.SpeedMaxOpt = Global.SpeedMaxOpt;
        Die.ProfilTempMaxOpt = Global.ProfilTempMaxOpt;
        Die.ProfilTempMinOpt = Global.ProfilTempMinOpt;

        Die.DieLoadMaxOpt = Global.DieLoadtMaxOpt;
        Die.DieLoadMinOpt = Global.DieLoadtMinOpt;
        .
        .
        .
 end
0

There are 0 best solutions below