필터 지우기
필터 지우기

How to convert or extract symbolic matrix expressions to string?

조회 수: 30 (최근 30일)
For symbolic matrix expression of symbolic matrix 'D', I want to convert or extract any variable type with char and str.
How to convert or extract symbolic matrix expressions to string?
Thank you.
N = 100;
A = symmatrix('A',[N, N]);
B = symmatrix('B',[N, N]);
C = symmatrix('C',[N, N]);
D = A*B*C;
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2023년 8월 1일
It might be difficult with symmatrix or maybe not even possible.
This might be a workaround -
N = 3;
syms A B C [N N]
D = A*B*C
D = 
E = string(D)
E = 3×3 string array
"C1_1*(A1_1*B1_1 + A1_2*B2_1 + A1_3*B3_1) + C2_1*(A1_1*B1_2 …" "C1_2*(A1_1*B1_1 + A1_2*B2_1 + A1_3*B3_1) + C2_2*(A1_1*B1_2 …" "C1_3*(A1_1*B1_1 + A1_2*B2_1 + A1_3*B3_1) + C2_3*(A1_1*B1_2 …" "C1_1*(A2_1*B1_1 + A2_2*B2_1 + A2_3*B3_1) + C2_1*(A2_1*B1_2 …" "C1_2*(A2_1*B1_1 + A2_2*B2_1 + A2_3*B3_1) + C2_2*(A2_1*B1_2 …" "C1_3*(A2_1*B1_1 + A2_2*B2_1 + A2_3*B3_1) + C2_3*(A2_1*B1_2 …" "C1_1*(A3_1*B1_1 + A3_2*B2_1 + A3_3*B3_1) + C2_1*(A3_1*B1_2 …" "C1_2*(A3_1*B1_1 + A3_2*B2_1 + A3_3*B3_1) + C2_2*(A3_1*B1_2 …" "C1_3*(A3_1*B1_1 + A3_2*B2_1 + A3_3*B3_1) + C2_3*(A3_1*B1_2 …"
E(1)
ans = "C1_1*(A1_1*B1_1 + A1_2*B2_1 + A1_3*B3_1) + C2_1*(A1_1*B1_2 + A1_2*B2_2 + A1_3*B3_2) + C3_1*(A1_1*B1_3 + A1_2*B2_3 + A1_3*B3_3)"
Lee Jong Hyun
Lee Jong Hyun 2023년 8월 1일
편집: Lee Jong Hyun 2023년 8월 1일
Thanks!

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

채택된 답변

Anjaneyulu Bairi
Anjaneyulu Bairi 2023년 8월 28일
I understand that you are trying to convert symbolic matrix expression into string.
You can use “string” function to convert it.
To avoid error while converting to string, please use “syms” like below instead of “symmatrix” to create symbolic matrix.
N=100
S = sym('S', [N N])
S_str=string(S)
“S_str” is the string form of “S” symbolic expression.
Hope it helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Variables, Expressions, Functions, and Preferences에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by