필터 지우기
필터 지우기

How to use fprintf for a symbolic matrix

조회 수: 3 (최근 30일)
Jade Henrichon
Jade Henrichon 2021년 2월 1일
답변: Star Strider 2021년 2월 1일
I have this :
syms n2 n1 R d ;
RS = [1, 0; -(n2-n1)/(n2*R), n1/n2];
P1 = [1, d ; 0, 1];
RF = [1, 0; 0, n2/n1];
Lplanoconvexe = RF*P1*RS;
I want to use fprintf to print my matrix 2x2 like a normal matrix and not on a single line like I have with this command : fprintf('%s', Lplanoconvexe.')

답변 (1개)

Star Strider
Star Strider 2021년 2월 1일
Try this:
syms n2 n1 R d ;
RS = [1, 0; -(n2-n1)/(n2*R), n1/n2];
P1 = [1, d ; 0, 1];
RF = [1, 0; 0, n2/n1];
Lplanoconvexe = RF*P1*RS;
C = sym2cell(Lplanoconvexe);
fprintf('%30s\t%30s\n', C{:})
producing:
(d*(n1 - n2))/(R*n2) + 1 (n1 - n2)/(R*n1)
(d*n1)/n2 1
.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by