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!