I need help with my code for a degree in IT
1 回表示 (過去 30 日間)
古いコメントを表示
CODE 1:
classdef SurfaceUnit
properties (Access = private)
Position
Threat
Certainty
end
methods
function obj = SurfaceUnit(varargin)
if nargin == 3
obj.Position = varargin{1};
obj.Threat = varargin{2};
obj.Certainty = varargin{3};
else
unit1 = SurfaceUnit([10,20],'FRD',0.9);
end
end
function out = getPosition(obj)
function setPosition(obj, p)
function out = getTreat(obj)
function setThreat(obj, t)
function out = getCertainty(obj)
function setCertainty(obj, c)
end
end
end
end
end
end
end
end
CODE 2:
classdef AttributeFusion
properties
Unit1
Unit2
FusedUnit
end
methods
function obj = AttributeFusion(u1,u2)
obj.Unit1 = u1;
obj.Unit2 = u2;
obj.FusedUnit = SurfaceUnit;
end
function out = getFusedUnit(obj)
out = obj.FusedUnit;
end
end
end
CODE 3:
clear; clc;
unit1 = SurfaceUnit([10,20],ThreatValues.FRD,0.9);
unit2 = SurfaceUnit([15,25],ThreatValues.ASF,0.8);
fision = AttributeFusion(unit1, unit2);
fusedUnit = fusion.getFusedUnit;
fusedUnit.getPosition
char(fusedUnit.getThreat)
Well the problem is, that I do not know why my program says that obj section is unused and it may require replacing it with ~.
0 件のコメント
回答 (1 件)
Walter Roberson
2024 年 10 月 19 日
function out = getPosition(obj)
function setPosition(obj, p)
function out = getTreat(obj)
function setThreat(obj, t)
function out = getCertainty(obj)
function setCertainty(obj, c)
end
end
end
end
end
end
Those are nested function definitions. setPosition is defined inside of getPosition, getTreat is defined inside of setPosition, and so on. None of the implementations use the input obj so MATLAB warns you that input obj is unused.
You are quite unlikely to want nested function definitions at that point.
2 件のコメント
Walter Roberson
2024 年 10 月 19 日
function out = getPosition(obj)
end
function setPosition(obj, p)
end
and so on.
Then populate the bodies of the functions with appropriate code, such as
out = obj.Position;
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!