Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Function error in if function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Christos Papagrigoriou
el 18 de Jun. de 2020
Cerrada: MATLAB Answer Bot
el 20 de Ag. de 2021
%%file y.m
% Define the function
function [ y ] = x( n )
if n < 0 | n >= 10
y = 0;
else
y = 5;
end
end
it turns back with Error in y (line 4)
if n < 0 | n >= 10
this is literally copied by my lecturers instructuons.
1 comentario
Respuestas (1)
Steven Lord
el 18 de Jun. de 2020
If you call your function like this:
y = x()
what value should MATLAB use in the if statement condition where it tries to validate the value of n?
if n < 0 | n >= 10
You need to tell the x function what n is, like:
y = x(5)
2 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!