Gradient command producing multiple functions

조회 수: 1 (최근 30일)
Gavin Seddon
Gavin Seddon 2016년 12월 5일
댓글: Jan 2017년 2월 14일
Hello, when I use the gradient command I am given multiple functions as the answer. I assume these are the gradient at each 'root'. Is it necessary to substitute X at a specific position to generate the gradient at the position? Furthermore, will quiver generate the slope field?
G.
  댓글 수: 2
Gavin Seddon
Gavin Seddon 2017년 2월 14일
Hello I have defined my distance function as d =
(5757*x^3)/100000 - (2227*x^2)/10000 + (1303*x)/2500 + 25/2 I then differentiate this to get diff (5757*x^3)/100000 - (2227*x^2)/10000 + (1303*x)/2500 + 25/2
ans =
(1303*x)/2500 - (4999*x^2)/100000 + 25/2 how would I calculate the gradient at varying X values?
Thanks and sorry for the delay. Gav.
Jan
Jan 2017년 2월 14일
@Gavin: Please do not attach a new question as a comment to another. Open a new thread instead.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2016년 12월 5일
The functions you obtain from the gradient function are the derivatives with respect to the vector of the used variables. See https://www.mathworks.com/help/symbolic/gradient.html .
  댓글 수: 2
Gavin Seddon
Gavin Seddon 2016년 12월 6일
Thank you, this is the page I used originally. Clearly I am getting the derivative of my initial function. I need the differential tangent to my curve at a specific X position. It is this page that shows the slope/vector field. As mentioned earlier should I pursue evaluating my gradient at a particular x position? Thank you again.
Jan
Jan 2016년 12월 9일
It would be easier to answer, if you provide some details. To get the gradient at a specific point, you have to insert the coordinate values into the obtained formula.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Guillaume
Guillaume 2016년 12월 5일
Ah, language. It's so hard to get yourself understood if you don't use the correct terms...
The gradient function does not return functions. Not one, not multiple. It returns numerical matrices / vectors.
It will return as many outputs as you have requested, so if you ask for multiple output, you'll get multiple outputs. If you ask for one, you'll only get one. Each output is the gradient of the input matrix along the corresponding dimension. I have no idea what you mean by 'root'
I also have no idea what this X you want to substitute is. You get the gradient at each point in your original matrix. If you want the gradient at points in between you either interpolate your input, or interpolate your output.
Finally, what is a slope field. quiver just plots arrow in the direction you specify. If it's the gradient of you matrix you want to plot with quiver, just pass the output of gradient to quiver (as per the example in the doc of gradient).
  댓글 수: 2
Jan
Jan 2016년 12월 5일
If you call gradient with symbolic expressions, you can obtain functions, see https://www.mathworks.com/help/symbolic/gradient.html .
Guillaume
Guillaume 2016년 12월 5일
Ah... I don't have the symbolic toolbox, so wasn't aware of this gradient overload.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by