anonymous function does not calculate a numbers
Show older comments
% 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.
Accepted Answer
More Answers (1)
Abdulaziz
on 27 Nov 2012
0 votes
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!