Borrar filtros
Borrar filtros

Unrecognized function or variable 'i1'.

3 visualizaciones (últimos 30 días)
Dan Giffin
Dan Giffin el 15 de Oct. de 2023
Comentada: Dan Giffin el 15 de Oct. de 2023
So this doesn't work if either of the t = 0:0.2:2 OR t = linspace(0,2,100); are commented or not.
How do I get it to work since the turorial sheet says that this exact code should work if I run:
[a,b,c] = ThreeFunc2(i1,i2,i3)
But it doesnt.
It gives the error:
Unrecognized function or variable 'i1'.

Respuesta aceptada

the cyclist
the cyclist el 15 de Oct. de 2023
The variables i1, i2, and i3 in the function call
[a,b,c] = ThreeFunc2(i1,i2,i3)
or the variables t, f1 and f2 in the function call
[a,b,c] = ThreeFunc2(t,f1,f2)
need to be defined before the function call, not just exist within the function. Those variables are expected as inputs.
  4 comentarios
the cyclist
the cyclist el 15 de Oct. de 2023
Your assignment explicitly states, "the time vector you specified in parameter i1", in other words you need to tell your function what i1 is.
The assignment is admittedly less clear on what to do with i2 and i3 (although it does say you can use a number for i3).
Dan Giffin
Dan Giffin el 15 de Oct. de 2023
Riiight, that makes a lot of sense.
Thanks for your time,
sorry for being slow.

Iniciar sesión para comentar.

Más respuestas (1)

Sam Chak
Sam Chak el 15 de Oct. de 2023
I think you can do something like this:
t = 0:0.01:10;
f1 = 1/10;
f2 = 1/5;
% Call the function
ThreeFunc2(t, f1, f2)
% Write the tasks to be carried function
function ThreeFunc2(t, f1, f2)
y1 = sin(2*f1*pi*t);
y2 = cos(2*f2*pi*t);
plot(t, [y1' y2']), grid on
end

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by