Clear Filters
Clear Filters

not enough input arguments

2 views (last 30 days)
Daniela
Daniela on 22 Apr 2024
Answered: Walter Roberson on 22 Apr 2024
Hello, here is my simple equation of a function to determine total pay after taxes. I'm new to Matlab and i'm getting an error in line 5 but im not really understanding why.
-------------------------------------------------------------------------------------
function [takehome_pay, taxes_paid, total_pay] =
PaycheckFunction(HoursWorked, HourlyWage, TaxRate)
end
% Function to determine your take home pay after taxes are taken out
total_pay = HoursWorked * HourlyWage;
taxes_paid = total_pay * TaxRate;
takehome_pay = total_pay - taxes_paid;
Not enough input arguments.
Error in PaycheckFunction (line 5)
total_pay = HoursWorked * HourlyWage;

Answers (2)

Cris LaPierre
Cris LaPierre on 22 Apr 2024
It looks like the end is in the wrong place. Move it to the bottom of your function.
function [takehome_pay, taxes_paid, total_pay] = PaycheckFunction(HoursWorked, HourlyWage, TaxRate)
% Function to determine your take home pay after taxes are taken out
total_pay = HoursWorked * HourlyWage;
taxes_paid = total_pay * TaxRate;
takehome_pay = total_pay - taxes_paid;
end

Walter Roberson
Walter Roberson on 22 Apr 2024
You are trying to run the function by pressing the green Run button. When you run the function by pressing the green Run button, the function is executed with no parameters.
MATLAB will never go searching in the environment to try to find values for variables that are named as parameters on the function line. You always have to supply any necessary values when you call the function.
Go down to the command line and invoke the function passing in appropriate values.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!