Here is a particular code. Can anyone please help me in taking the analytical (partial) derivative of the function 'F' along X (i.e., w.r.t. X) along Y (i.e., w.r.t. Y) and along the diagonal (i.e., w.r.t. X plus w.r.t. Y) using matlab command.
Thank you sir for your answers. Actually I need the analytical derivative of the function and the value of it at each point in the defined range. i.e. diff (F,X)=4*3^(1/2)*X; is giving me the analytical derivative of the function. After finding this I also need to find its value at each point of X( i.e., for X=(-1:2/511:+1). Similarly the others.
For clarification, the numerical and symbolic calculations are fairly similar code wise. Walter has provided the symbolic gradients (as requested), while Youssef has provided the numerical ones. One correction is that dX = matlabFunction(diff(F,x)) is only a function of x, which is why it generates an error when calling dX(x,y).
To go in a bit more detail on Walter's suggested solution:
clear
% Define Mesh
[ X,Y] = meshgrid(-1:2/10:1,-1:2/10:1); % Using 2/10 as spacing
Good morning, I also have the same question, I have consulted a lot on the web, but they always give answers as if the surface were symbolic, but it is numerically and the calculation of the partial derivative of a matrix of order mxn remains.
Please take a look at my comment above. The surface values are found by substituting/evaluating the symbolic expression at the grid points. Assuming you are using R2021b or later, you may find symmatrix useful for manipulation of matrix expressions, e.g. gradient of matrix multiplication
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.