Borrar filtros
Borrar filtros

matric component of symbolic fuction

1 visualización (últimos 30 días)
Jinho Lee
Jinho Lee el 1 de Mayo de 2022
Respondida: Walter Roberson el 1 de Mayo de 2022
I'm using matlab live editor and trying to get a specific component of a variable function of matric
-------------------------------------------
clc
clear all
syms r Phi(r) Lambda(r) theta t phi
xa=[t;r;theta;phi]
n=4;
g=[-exp(-2*Phi),0,0,0; 0, exp(-2*Lambda),0, 0; 0,0,r^2*theta^2,0; 0,0,0,r^2* (sin(theta))^2 ]
-----------------------------
for example I would like to have g(1,1) but g is function of r, g(1,1) doesn't work...
Is there any good way to figure our this problem..?
I need "for" loop to calculate some symbolic algebra for each component
Thanks in advance

Respuestas (1)

Walter Roberson
Walter Roberson el 1 de Mayo de 2022
There is no way to do that in MATLAB, at least not without knowing the internal operations of the Symbolic engine.
In MATLAB when you create a symbolic function that is non-scalar, there is no way (short of internal operations) to index the function to get to one particular calculation.
You have several options at this point:
  • call the symbolic function passing in symbolic parameters, getting out a symbolic array that you then index; or
  • create g as a cell array instead of using []. You would not be able to directly do things such int(g) or directly evaluate g at a parameter, but you would be able to index; or
  • use unsupported calls into the symbolic engine and arcane knowledge to do the indexing.

Community Treasure Hunt

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

Start Hunting!

Translated by