Differential Operator in Matlab in 1 Dimension

111 visualizaciones (últimos 30 días)
MarshallSc
MarshallSc el 12 de Dic. de 2021
Comentada: Walter Roberson el 7 de En. de 2022
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 comentarios
asdsa sad
asdsa sad el 7 de En. de 2022
Have you solved this problem? Is there a suitable way to express differential operators? I need d2/dt2
Walter Roberson
Walter Roberson el 7 de En. de 2022
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

Iniciar sesión para comentar.

Respuesta aceptada

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

Más respuestas (1)

Chris
Chris el 12 de Dic. de 2021
Editada: Chris el 12 de Dic. de 2021
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 comentarios
Walter Roberson
Walter Roberson el 12 de Dic. de 2021
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 el 12 de Dic. de 2021
Editada: MarshallSc el 12 de Dic. de 2021
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).

Iniciar sesión para comentar.

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by