フィルターのクリア

differentiation with respect to space

9 ビュー (過去 30 日間)
friet
friet 2017 年 6 月 24 日
回答済み: Star Strider 2017 年 6 月 24 日
Hello I am doing differentiation with respect to space. I have a function y which is x^2. x is my coordinate. I want to differentiate y with respect to x and I use 'diff' function. I know dy/dx=2*x. so I compare my result of differentiating (in fig3) with the plot of y=2*x (fig.2) and they are not the same. And also how can I have the same length after differentiating? Any help is appreciated. friet.
clear all clc
x=linspace(-1,1,100);
y=x.^2;
figure(1)
plot(x,y)
z=2.*x;
figure(2)
plot(x,z)
u=diff(y,x);
figure(3)
plot(x(1:99),u)

回答 (1 件)

Star Strider
Star Strider 2017 年 6 月 24 日
Since you are doing numeric, rather than symbolic, differentiation, use the gradient (link) function, not diff.

カテゴリ

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