how to get float answer and not a Fraction ?

93 ビュー (過去 30 日間)
tomer polsky
tomer polsky 2019 年 5 月 5 日
編集済み: Stephan 2019 年 5 月 5 日
lets say this is my code ,(simple code ) :
for some reason my answer is fraction and float point anser ,how to fix the format ?
clc;
clear all;
syms R2
R1=200
eqn=(12*R2)/(R2+R1)==5
sol_R2=simplify(solve(eqn,R2))

回答 (1 件)

Stephan
Stephan 2019 年 5 月 5 日
編集済み: Stephan 2019 年 5 月 5 日
Hi,
symbolic calculatuions are always precise. If you want a float point answer, you have to tell it to matlab:
% one way:
sol__R2_num1 = double(sol_R2)
% The other way:
sol_R2_num2 = simplify(vpasolve(eqn,R2))
Best regards
Stephan

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by