What instruction could give me this result?
조회 수: 1 (최근 30일)
이전 댓글 표시
If I have the following matrix in MATLAB;
syms a;
A=[a, a+1/2 ; a+1/3, a+1/4]
And I want to obtain the next result using one instruction;
[ a (2*a+1)/2 ]
[ (3*a+1)/3 (4*a+1)/4 ]
What instruction could perform this? Thanks in advance!
댓글 수: 2
답변 (1개)
Walter Roberson
2021년 5월 10일
You cannot get MATLAB to display in that particular way as a symbolic expression. You can convert to character and display.
syms a;
A=[a, a+1/2 ; a+1/3, a+1/4]
[n, d] = numden(A)
categorical(arrayfun(@(n,d) "(" + n + ")/" + d, string(n), string(d)))
You would need more work to eliminate the () for the cases where there is nothing being added.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!