not enough input arguments
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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;
0 Kommentare
Antworten (2)
Cris LaPierre
am 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
0 Kommentare
Walter Roberson
am 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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Function Creation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!