Info

This question is closed. Reopen it to edit or answer.

Using a for loop to build a funciton

1 view (last 30 days)
Dalton Lambert
Dalton Lambert on 7 Dec 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
I have an array and those are supposed to act as the integers for each x in the function expcet the data may change depending on what is entered. Thus i would like to have a function that is built with a for loop then i can take the derrivative of that. I am not sure I am very clear.
for i = 1:order+1
f = @(z) yp(i)*z^(i-1);
end
Basicailly I want it to add to the funciton for each position of yp
  1 Comment
dpb
dpb on 8 Dec 2019
It is definitely so that your explanation is not at all clear what you're trying to accomplish.
"the data may change depending on what is entered"
Which data changes and what, specifically, does "what is entered" refer to?
Whatever are the variables in the RHS of the definition of an anonymous function are embedded in the function when it is created. Only the dummy argument variable is changeable by subsquently calling the function.

Answers (0)

Community Treasure Hunt

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

Start Hunting!