How to use fprintf for a symbolic matrix

8 visualizzazioni (ultimi 30 giorni)
Jade Henrichon
Jade Henrichon il 1 Feb 2021
Risposto: Star Strider il 1 Feb 2021
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.')

Risposte (1)

Star Strider
Star Strider il 1 Feb 2021
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
.

Community Treasure Hunt

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

Start Hunting!

Translated by