anonymous function does not calculate a numbers
Afficher commentaires plus anciens
% Hi guys please I need help with an issue I could not figure.
>> % This is simplified example of my issue
>> for i=1:5
y=i*x^2;
dy=diff(y,x);
g=@(x)dy;% this equation is changing in each iteration due to 'i'.
m=g(i)
end
m =2*x
the anonymous function does not account for the i, it always gives the variable x in the m equation.
Réponse acceptée
Plus de réponses (1)
Abdulaziz
le 27 Nov 2012
0 votes
Catégories
En savoir plus sur Common Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!