Calculate the length of symbolic expression

10 ビュー (過去 30 日間)
T S Singh
T S Singh 2020 年 2 月 18 日
コメント済み: T S Singh 2020 年 2 月 19 日
Hi,
I am trying to caculate the total length of a symbolic expression.
Eg.
syms x a b
df=x^2+2*a*b
I want to cacluale the length of 'df', in my case the answer should be nine (including operator).
I am using MATLAB 2015a.
Any help please.

採用された回答

KSSV
KSSV 2020 年 2 月 18 日
S = char(df) ; % convert sym to string
idx = strfind(s,' ') ; % get empty spaces
S(idx) = [] ; % remove the mepty spaces
iwant = length(S)
  1 件のコメント
T S Singh
T S Singh 2020 年 2 月 19 日
Thanks KSSV

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by