Question about hard coding error
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Bruno Fulco Mancini
el 25 de Mayo de 2020
Comentada: Alejandro Peñuelas
el 25 de Mayo de 2020
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 comentario
Alejandro Peñuelas
el 25 de Mayo de 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.
Respuestas (1)
Walter Roberson
el 25 de Mayo de 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 comentarios
Ver también
Categorías
Más información sobre Large Files and Big Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!