Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Why is my function not working?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I wrote this in a coding window:
function z = z(x)
z = (v^(x/2)-v^(-x/2))/(t^(x/2)-t^(-x/2));
end
then I saved it, went to the command prompt and typed z(3). I want my result to be:
(v^(3/2)-v^(-3/2))/(t^(3/2)-t^(-3/2))
But instead i get:
Error in z (line 2)
z = (v^(x/2)-v^(-x/2))/(t^(x/2)-t^(-x/2));
What is going wrong here? Thanks!
0 commentaires
Réponses (2)
madhan ravi
le 24 Sep 2020
Modifié(e) : madhan ravi
le 24 Sep 2020
syms v t % in the first line of function
0 commentaires
Ameer Hamza
le 24 Sep 2020
Because you haven't defined the values of v and t inside the function. Change to something like this
function z = z(x)
v = 1;
t = 2;
z = (v^(x/2)-v^(-x/2))/(t^(x/2)-t^(-x/2));
end
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!