Borrar filtros
Borrar filtros

Evaluate symbolic matrix numerically.

32 visualizaciones (últimos 30 días)
Andrew
Andrew el 17 de Abr. de 2011
Comentada: Mohamed Hajjaj el 16 de Abr. de 2021
Hi,
I am trying to figure out how to evaluate a matrix that contains variables numerically.
For example:
syms A B;
matrix = [1-A, 1-B; 6*A, 10*B];
A = 0.5
B = 1.0
matrix
For me, this just displays:
A =
0.5000
B =
1
matrix =
[ 1 - A, 1 - B]
[ 6*A, 10*B]
How can I get the matrix to be evaluated numerically with the newly defined numbers? This is an extremely simplified version of what I am trying to do. In my actual program, I am taking the jacobian of a matrix symbolically, and then I need to evaluate the matrix numerically, therefore in this small example, I cannot simply move A & B above the "matrix = [1-A, 1-B; 6*A, 10*B];" line. Basically, is there a way to evaluate a matrix numerically after assembling the matrix with variables?

Respuestas (1)

Jiro Doke
Jiro Doke el 17 de Abr. de 2011
Use subs:
subs(matrix, {A, B}, {0.5, 1})
  2 comentarios
Manuel Escobar
Manuel Escobar el 23 de En. de 2021
IT WORK! THANKS
Mohamed Hajjaj
Mohamed Hajjaj el 16 de Abr. de 2021
If the matrix Phi is dependent on one parameter( say t), can I use Phi (T) to get the numeric value of Phi at numeric value T?
The below link may explain this question:
at the following section:
[n,n1]=size(Phi);
PhiT = zeros(n);
for i = 1:n
for j = 1:n
PhiT(i,j) = Phi{i,j}(T);
end
end
B = logm(PhiT)/T;
Any help would be appreciated.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by