フィルターのクリア

how can i find the gradient of this function

3 ビュー (過去 30 日間)
Anar Alshanbayeva
Anar Alshanbayeva 2016 年 1 月 7 日
回答済み: Star Strider 2016 年 1 月 7 日
hi everyone, I am trying to calculate the gradient of this function (in X and Y direction): Lw=sum(w(x,y) * l (x, y)); where l = (sqrt( (x(i+1)-x(i))^2-(y(i+1)-y(i))^2 ));
and what I do is for the X direction: coef=( w*(x(i+1)-x(i))/( (x(i+1)-x(i))^2+(y(i+1)-y(i))^2 ) ); Gx(i)=gwx* (sqrt( (x(i+1)-x(i))^2-(y(i+1)-y(i))^2 )) + ( w*(x(i+1)-x(i))/( (x(i+1)-x(i))^2+(y(i+1)-y(i))^2 ) ); Gx(i)=Gx(i)+coef;
For the y direction: coef2=( w*(y(i+1)-y(i))/( (x(i+1)-x(i))^2+(y(i+1)-y(i))^2 ) ); Gy(i)=gwy* (sqrt( (x(i+1)-x(i))^2-(y(i+1)-y(i))^2 )) + ( w*(y(i+1)-y(i))/( (x(i+1)-x(i))^2+(y(i+1)-y(i))^2 ) ); Gy(i)=Gx(i)+coef2;

回答 (1 件)

Star Strider
Star Strider 2016 年 1 月 7 日
I cannot follow the code in your post that you want to work with. There are Symbolic Math Toolbox functions that can calculate the gradient of a symbolic function if you want to do that.
To calculate a numerical gradient, I would start by defining the x and y ranges of values using the meshgrid function, then use the gradient function to do a numerical gradient calculation. See the documentation for those functions for the details. (Both meshgrid and gradient are core MATLAB functions so you do not need any additional Toolboxes to use them.)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by