strange format of result(division operation)

8 ビュー (過去 30 日間)
shirin mhd
shirin mhd 2022 年 3 月 25 日
コメント済み: shirin mhd 2022 年 3 月 25 日
Hi everyone
I've written this code:
syms x
>> f=-5e-6*((x).^2)+3.21e2*(x);
>> eq=diff(f)==0;
>> allocate=solve(eq)
and the answer should be a number. but what I get after running the code is :
allocate =
189484955125144514199552/5902958103587057
that is not what I expect!
Matlab doesn't do the division operation and I wnat have the final result that is a number. what should i do?
I really appreciate your help.

採用された回答

Chunru
Chunru 2022 年 3 月 25 日
Symbolic computation tries its best not to loose accuracy. You can convert it to a number at the end
syms x
f=-5e-6*((x).^2)+3.21e2*(x);
eq=diff(f)==0;
allocate=solve(eq)
allocate = 
final_sol = double(allocate)
final_sol = 3.2100e+07
  1 件のコメント
shirin mhd
shirin mhd 2022 年 3 月 25 日
Thank you so much Chunru.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by