Round polynomial coeff symbolic

4 ビュー (過去 30 日間)
amin ya
amin ya 2019 年 7 月 8 日
回答済み: amin ya 2019 年 7 月 8 日
As built in Matlab lacks this, I have written a code to find coeffitients that are very small:
function symRound=coeffRounder(symExp)
% search all elements of a matrix
for i=1:size(symRound,1)
for j=1:size(symRound,2)
[C,T]=coeffs(symRound(i,j));
isSmall=logical(abs(c)<1e-16);
C(isSmall)=0;
symRound(i,j)=dot(C,T);
end
end
symRound=symExp;
end
Is there any way to avoid this and solve the problem without this function?
This is caused because of
syms x
cos(-pi/2)*x
I also used the 2nd and 3rd syntax from here:
Pi = sym(pi, 'f') %if you want it treated as 884279719003555/281474976710656
Pi = sym(pi, 'd') %if you want it treated as symbolic 3.1415926535897931159979634685442
Non of them gives 0 for
syms x
cos(-pi/2)*x

採用された回答

amin ya
amin ya 2019 年 7 月 8 日
Ok, 3rd method works strangely.
Pi = sym('pi'); %if you want it treated as symbolic

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by