How can I insert the value of a symbol in symbolic matrix and convert it into a numerical matrix?

조회 수: 19 (최근 30일)
syms t
PHI=[ 1, t, t/3 - (2*exp(-3*t))/9 + 2/9, (2*t)/3 + (2*exp(-3*t))/9 - 2/9;
0, 1, (5*exp(-3*t))/12 - (3*exp(t))/4 + 1/3, 2/3 - exp(t)/4 - (5*exp(-3*t))/12;
0, 0, exp(-3*t)/4 + (3*exp(t))/4, exp(t)/4 - exp(-3*t)/4;
0, 0, (3*exp(t))/4 - (3*exp(-3*t))/4, (3*exp(-3*t))/4 + exp(t)/4];
PHIT=transpose (PHI);
B=[0;1;2;1];
BT=transpose (B);
GRAM = PHI*B*BT*PHIT
%When t=1, Need to find the GRAM matrix

답변 (2개)

David Hill
David Hill 2019년 12월 7일
t=1;
subs(GRAM);

Star Strider
Star Strider 2019년 12월 7일
Please see Plotting error: Need to plot the evolution of symbolic matrix? to convert it to a numerical matrix (as an anonymous function).
  댓글 수: 4
Shauvik Das
Shauvik Das 2019년 12월 7일
It does not help.
Code:
syms t
PHI=[ 1, t, t/3 - (2*exp(-3*t))/9 + 2/9, (2*t)/3 + (2*exp(-3*t))/9 - 2/9;
0, 1, (5*exp(-3*t))/12 - (3*exp(t))/4 + 1/3, 2/3 - exp(t)/4 - (5*exp(-3*t))/12;
0, 0, exp(-3*t)/4 + (3*exp(t))/4, exp(t)/4 - exp(-3*t)/4;
0, 0, (3*exp(t))/4 - (3*exp(-3*t))/4, (3*exp(-3*t))/4 + exp(t)/4];
PHIT=transpose (PHI);
B=[0;1;2;1];
BT=transpose (B);
GRAM = PHI*B*BT*PHIT
%% Now I want replace t=1 for the matrix Gram??
Star Strider
Star Strider 2019년 12월 7일
Try this:
PHI = @(t) [ 1, t, t/3-(2*exp(-3*t))/9+2/9, (2*t)/3+(2*exp(-3*t))/9-2/9;
0, 1, (5*exp(-3*t))/12-(3*exp(t))/4+1/3, 2/3-exp(t)/4-(5*exp(-3*t))/12;
0, 0, exp(-3*t)/4+(3*exp(t))/4, exp(t)/4-exp(-3*t)/4;
0, 0, (3*exp(t))/4-(3*exp(-3*t))/4, (3*exp(-3*t))/4+exp(t)/4];
PHIT = @(t) transpose(PHI(t));
B=[0;1;2;1];
BT=transpose(B);
GRAM = @(t) PHI(t)*B*BT*PHIT(t);
calling:
t = 1
GRAM(t)
produces:
t =
1
ans =
6.4744 -6.1142 12.136 12.009
-6.1142 5.774 -11.461 -11.341
12.136 -11.461 22.748 22.51
Make appropriate changes to get different results.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by