I made a function and m-file to call that function but for some reason its giving me an error of "Undefined function or variable y" please help to fix my code
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Aijalon Marsh
el 8 de Mzo. de 2022
Editada: Cris LaPierre
el 10 de Mzo. de 2022
Function:
function MagnitudeRatio2ndOrder(E, W, w)
y= 1/(sqrt((1-(w/W)^2)^2+((2*E*w)/W)^2));
end
New m-file:
clear
E = 0.3;
W = 1;
w = 0;
hold on
MagnitudeRatio2ndOrder(E, W, w);
results = y;
disp(results)
0 comentarios
Respuesta aceptada
Cris LaPierre
el 8 de Mzo. de 2022
Editada: Cris LaPierre
el 10 de Mzo. de 2022
First, you need to define your function declaration to have an output variable. It looks like you want it to return y.
You need to assign the output of your function to a variable if you wish to use it. It looks like you want to name the variable results. You could do this
E = 0.3;
W = 1;
w = 0;
results = MagnitudeRatio2ndOrder(E, W, w)
function y = MagnitudeRatio2ndOrder(E, W, w)
y= 1/(sqrt((1-(w/W)^2)^2+((2*E*w)/W)^2));
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Web Services 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!