Passing an object from a method function to another function
古いコメントを表示
I'm having trouble passing an object from a method function to another function.
I want to pass the obj.federaltax and obj.provincialTax to my calc_totalTax func to calcluate the totalTax but all i'm getting is an empty value for totalTax.
classdef calcTax
properties
income = input('enter annual income: ');
federalTax;
provincialTax;
totalTax;
end
function obj = calc_federalTax(obj)
if obj.income <= 46605
obj.federalTax = obj.income*15/100;
else
obj.federalTax = obj.income*15/100;
end
end
function obj = calc_provincialTax(obj)
if obj.income <= 42960
obj.provincialTax = obj.income*5.05/100;
else
obj.provincialTax = obj.income*9.15/100;
end
end
function obj = calc_totalTax(obj)
obj.totalTax = obj.provincialTax + obj.federalTax
disp(totalTax)
end
end
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!