signal statues Name function
Mostrar comentarios más antiguos
I have trouble delaing with one of my homework questions, and here is the question:
When the function is called, myParamwill contain a single character. When properly called, the function must return a character array with a message based on the instructions that follow.
If myParamcontains gthen it must return a character array containin green.
If myParamcontains ythen it must return a character array containin yellow.
For all other cases, it must return a character array containin red.
I wrote my code as this:
res = getSignalStatusName(myParam)
myParam = 'k';
if myParam == 'g'
res = 'green';
elseif myParam == 'y'
res = 'yellow';
elseif myParam == 'r'
res = 'red';
end
end
But when I ran the code, it showed that
Undefined function or variable 'res'.
Does anyone can help me about this issue? Thanks.
Respuestas (1)
Stephan
el 3 de Mzo. de 2019
Hi,
you fogot to specify that it is a function. This is why the error occurs:
function res = getSignalStatusName(myParam)
if myParam == 'g'
res = 'green';
elseif myParam == 'y'
res = 'yellow';
elseif myParam == 'r'
res = 'red';
end
end
I recommend to check this code again and test it against the conditions of your description. Does it really do what is wanted? I leave it to you to find this out, since it is a homework.
Best regards
Stephan
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!