# How can i put the values in gradient of a function obtained through the gradient command?

1 visualizzazione (ultimi 30 giorni)
RADHIKA GOUR il 30 Nov 2018
Modificato: VBBV il 21 Apr 2024
TT=[1 1 1 1];
syms p0 p1 p2 p3 p4;
f_function = log(noise+p1*TT(1)+p2*TT(2)+p3*TT(3)+p4*TT(4));
f_gradient = gradient(f_function,[p0, p1, p2, p3, p4]);
Here I got f_gradient function of p1,p2,p3, p4.
now i want to evaluate it by putting p0=2, p1=2,..likewise...
How can I do this.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

VBBV il 21 Apr 2024
Modificato: VBBV il 21 Apr 2024
@RADHIKA GOUR, you can use subs and plug-in the values for p1,p2,p3, p4 variables.
TT=[1 1 1 1];
noise = randi([2 10]);
syms p0 p1 p2 p3 p4;
f_function = log(noise+p1*TT(1)+p2*TT(2)+p3*TT(3)+p4*TT(4));
f_gradient = gradient(f_function,[p0, p1, p2, p3, p4])
f_gradient = double(subs(f_gradient,{p1,p2,p3,p4},{2,2,1,4})) % give some values and use subs
0 0.0714 0.0714 0.0714 0.0714
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by