how to modify displayed result

조회 수: 1 (최근 30일)
Opariuc Andrei
Opariuc Andrei 2020년 11월 9일
댓글: Rik 2020년 11월 9일
so i've got my code all functioning and all,how can i get matlab do display/calculate the divisions from sol (solution)? if possible i would like more response variants
  댓글 수: 2
Rik
Rik 2020년 11월 9일
It looks like you need to either set format to something else, or use double to convert the result. Without being able to copy and run your code it I can't tell which it is.
Opariuc Andrei
Opariuc Andrei 2020년 11월 9일
%% Input data
m1=2; m2=2.5; m3=3; k1=10; k2=15; k3=20; g=9.81;
%% calculus
syms x1 x2 x3
[A,b]=equationsToMatrix([m1*g+k2*(x2-x1)-k1*x1 m2*g+k3*(x3-x2)+k2*(x1-x2) m3*g+k3*(x2-x3)],[x1 x2 x3]);
sol=A\b

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

채택된 답변

Rik
Rik 2020년 11월 9일
%% Input data
m1=2; m2=2.5; m3=3; k1=10; k2=15; k3=20; g=9.81;
%% calculus
syms x1 x2 x3
[A,b]=equationsToMatrix([m1*g+k2*(x2-x1)-k1*x1 m2*g+k3*(x3-x2)+k2*(x1-x2) m3*g+k3*(x2-x3)],[x1 x2 x3]);
sol=A\b
sol = 
sol_as_double=double(sol)
sol_as_double = 3×1
7.3575 10.9545 12.4260
  댓글 수: 1
Rik
Rik 2020년 11월 9일
There seems to something wrong with the display fractional output (the code running feature is still being tested). It is the same as what you posted, so the conversion to double should also work for you.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by