Multiple functions working together?
Mostrar comentarios más antiguos
here is my code in a script coding window:
function [n] = n(x)
syms q
[n]=(q^(x/2)-q^(-x/2))/(q^(1/2)-q^(-1/2));
end
function d=d(x)
d=n(x+1)
end
I then save this and go to the command window and type in d(3), which I would like the output to be equal to n(4), but instead I get this:
Index exceeds the number of array elements (1).
Error in sym/subsref (line 870)
R_tilde = builtin('subsref',L_tilde,Idx);
What the heck is going on!!? I'm new to this, help appreciated!
Respuesta aceptada
Más respuestas (1)
David Hill
el 24 de Sept. de 2020
syms q
n=@(x)(q^(x/2)-q^(-x/2))/(q^(1/2)-q^(-1/2));
d=@(x)n(x+1);
1 comentario
Michael Vaughan
el 24 de Sept. de 2020
Categorías
Más información sobre MATLAB 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!