not enough input arguments
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Cris LaPierre
le 22 Avr 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 commentaires
Walter Roberson
le 22 Avr 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 commentaires
Voir également
Catégories
En savoir plus sur Function Creation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!