Gradient command producing multiple functions
显示 更早的评论
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
2017-2-14
Jan
2017-2-14
@Gavin: Please do not attach a new question as a comment to another. Open a new thread instead.
采纳的回答
更多回答(1 个)
Guillaume
2016-12-5
1 个投票
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
2016-12-5
If you call gradient with symbolic expressions, you can obtain functions, see https://www.mathworks.com/help/symbolic/gradient.html .
Guillaume
2016-12-5
Ah... I don't have the symbolic toolbox, so wasn't aware of this gradient overload.
类别
在 帮助中心 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!