Why properties of class is not initialized ?
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
classdef EKF
   properties
      is_initialized_ = false;
      previous_timestamp_ = 0;
      H_jacobian = zeros(3, 4);
      %measurement covariance matrix - laser
      R_laser_ = [0.0225, 0;
                  0, 0.0225];
      noise_ax;
      noise_ay;
   end
   methods
      function obj = EKF(obj)
       obj.noise_ax = 5;
       obj.H_laser_ = [1, 0, 0, 0;
          0, 1, 0, 0];
      end
   end
end 
When I create an object of this class, I just get back. WHy these properties are not initialized ?
> obj = EKF
  EKF with properties:
    Value: []
0 件のコメント
回答 (1 件)
  Robert U
      
 2018 年 12 月 7 日
        Hi Hafiz Luqman
The class definition you posted is errornous. The property "H_laser_" is not defined. So the constructor returns error:
test = EKF
No public property H_laser_ exists for class EKF.
Error in EKF (line 19)
       obj.H_laser_ = [1, 0, 0, 0;
While programming oop and evaluating changes of code it happens that earlier class definitions remain in memory. You could try to use
       clear all     
The corrected class definition (without questioning the sense) is working without troubles and as expected:
classdef EKF
   properties
      is_initialized_ = false;
      previous_timestamp_ = 0;
      H_jacobian = zeros(3, 4);
      %measurement covariance matrix - laser
      R_laser_ = [0.0225, 0;
                  0, 0.0225];
      noise_ax;
      noise_ay;
      H_laser_;
   end
   methods
      function obj = EKF(~)
       obj.noise_ax = 5;
       obj.H_laser_ = [1, 0, 0, 0;
                       0, 1, 0, 0];
      end
   end
end 
Kind regards,
Robert
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Construct and Work with Object Arrays についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

