Differential Operator in Matlab in 1 Dimension

91 次查看(过去 30 天)
In common, the differential operation is defined as "dy/dx" which means differentiate y with respect to x and in matlab it's defined by "diff()". But how can we define "d/dx" which means differentiate with respect to x. Basically it shows an operation in 1 dimension rather 2. This definition is used in many fields such as Einstein theories and geometry. For example, If we have a scalar as [a1] in initial point and [a2] at the secondary position, d/dx denotes how much a2 changed with respect to a1. Does Matlab has a specific operator for this or any way that we can define it so that it can be used in higher order differential equations?
There was a post here:
But there was no correct answer.
I'd appreciate any opinions!
  2 个评论
asdsa sad
asdsa sad 2022-1-7
Have you solved this problem? Is there a suitable way to express differential operators? I need d2/dt2
Walter Roberson
Walter Roberson 2022-1-7
No, there is no way in MATLAB to express differential operators without writing your own class or writing functions on top of the Symbolic Toolbox

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2021-12-12
You would need to create a new MATLAB class to handle everything related to this. MATLAB has no support for this built-in.

更多回答(1 个)

Chris
Chris 2021-12-12
编辑:Chris 2021-12-12
I'm not a math major so there's probably something technically wrong about this statement, but "d/dx" is essentially "dy/dx", replacing y with an arbitrary function of x. The only operators Matlab has by default are listed here. Most everything else is a function, which means the code it operates on likely needs to be enclosed in parentheses.
If you're using the symbolic toolbox, I believe the diff function should suffice for what you're asking. You could also define an inline function to describe exactly the derivative you want.
syms y(x,z) x z
y = x^2 + 5*z;
diff(y) % d/dx
ans = 
diff(y,z) % d/dz
ans = 
5
ddz = @(a) diff(a,z); % Inline d/dz
ddz(y)
ans = 
5
There is also the numerical (vs. symbolic) diff, which might work for the situation you describe:
h = 2; % Step size
aa = [5,10,14]; % Vector of values
ddx = diff(aa)/h
ddx = 1×2
2.5000 2.0000
Some common items that employ derivatives are the Jacobian and the Hessian
  2 个评论
Walter Roberson
Walter Roberson 2021-12-12
The poster is referring to a branch of mathematics which deals with "operators" that look like expressions. One of the common ways of writing the differential operator is D . Something like
(D+2*D^2+1) * (sin(x))
would be intended to mean
diff(sin(x),x) + 2 * diff(sin(x),x,x) + sin(x)
but the (D+2*D^2 +1) would be held in a variable (or array), not as a function handle or symbolic function, and application of the derivatives would be by using the multiplication operator.
You can, in part, use symbolic expressions in a variable named D, but at some point you need to apply the derivative operations.
MarshallSc
MarshallSc 2021-12-12
编辑:MarshallSc 2021-12-12
Thanks @Chris for your answer. I'm looking at it from the perspective @Walter Roberson, in a sense, just described. It is related to the measuring distances in Manifolds (Geodesics) that does not consider extrinsic view of the system, instead intrinsic properites are considered. In which, a differential equation is given and the possible solutions which are basis vectors (due to the lack of existance of position vectors) are analyzed (with assuming 2D basis vectors embedded in the coordinate information).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by