필터 지우기
필터 지우기

How do I make fprintf to show symbolic math?

조회 수: 66 (최근 30일)
Rustem
Rustem 2018년 2월 14일
댓글: Walter Roberson 2020년 5월 28일
I am solving for sigma_y and I used the solve function and symbolic math. In the end I need fprintf to display the formula in the form 'v*sigz', but it doesn't do this with the current fprintf. The pictures are there to better explain what I am doing.
syms epsy E sigy v sigx sigz
epsy = 0
sigx = 0
eqn = epsy == (1/E)*(sigy-(v*(sigx+sigz)))
sigy = solve(eqn,sigy)
fprintf('%0.2f mm.\n',sigy)

채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 14일
fprintf('%s mm.\n', char(sigy))
  댓글 수: 2
Lam Nguyen Van
Lam Nguyen Van 2020년 5월 25일
Help me! I want to fprintf equation matrix:
Walter Roberson
Walter Roberson 2020년 5월 25일
You cannot fprintf symbolic expressions in "pretty" formats. fprintf can only output characters in the first 16 bits of the Unicode planes.
https://www.compart.com/en/unicode/U+2093 shows subscript x in Unicode. However there is no subscript y.
Anything like the tall { cannot be created in Unicode.
The closest you can get in such cases is to emit encodings of the equations, such as using latex or MathML.

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

추가 답변 (1개)

Lam Nguyen Van
Lam Nguyen Van 2020년 5월 28일
Help me! I want to creat a Symbolic Matrix:
A = [ε ε ε;
ε ε ε]
I used the command, but:
syms A epsilon
epsilon = [ char(949) char(949) char(949)
char(949) char(949) char(949) ]
epsilon (2)
epxilon = sym('epsilon', [2 3])
A = zeros (2, 3);
for i = 1:6
epsilon = char(949);
A(i) = epsilon;
end
A
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 5월 28일
You cannot do it in a nicely printable form in normal MATLAB .m files.
However in Live Script, you get a nice display if you use
syms epsilon
A = ones(2,3) * epsilon

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

카테고리

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