Question about hard coding error
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I am using MATLAB grader and I received a message in one of the tests saying that: "it may have been that you hard coded some of the input values from the "code to call your function box". What does this error mean and how can i fix it?
Thank you
1 Commento
Alejandro Peñuelas
il 25 Mag 2020
Hi. Hard coding happens when you define the value of a variable directly when it must be defined in the arguments of a function.
I would help if you provide some part of the source code that produces this error or even screenshots so we can help you better. Thanks.
Risposte (1)
Walter Roberson
il 25 Mag 2020
Suppose that you are required to build a function f(x,y), and you happen know it will be called with y = 19, but you write the code like
function z = f(x,y)
y = 19; %this hard-codes a value for y instead of taking it from input
z = x.^2 - y.^3;
end
You would have ignored the value that was passed into your code and would have used your own file instead.
0 Commenti
Vedere anche
Categorie
Scopri di più su Software Development Tools in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!