# How to compute numerical gradient of an unknown function in matlab Simulink?

13 views (last 30 days)

Show older comments

##### 0 Comments

### Answers (1)

Torsten
on 19 Jul 2019

The i'th component gi of the gradient vector g is approximately given by

gi = (f(x1,...,xi+h,...,x10)-f(x1,...,xi,...,x10))/h

Thus for each time t, given (x1,...,x10), you will have to evaluate f at (x1+h,x2,...,x10),(x1,x2+h,x3,...,x10),...,(x1,x2,...,x10+h) and calculate the gi.

##### 10 Comments

Torsten
on 22 Jul 2019

Edited: Torsten
on 22 Jul 2019

How can you give both u(w) and u(w+h) to the system?

If this is a technical problem that concerns SIMULINK, I can't answer it.

As you wrote, u is the control input specified by you. So in general, it should be possible to evaluate it at (x(t),w(t)) and (x(t),perturbed w(t)).

### See Also

### Community Treasure Hunt

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

Start Hunting!