フィルターのクリア

How does symvar work?

1 回表示 (過去 30 日間)
sadel
sadel 2011 年 6 月 7 日
Hi all!
symvar 'cos(2*pi*t)'
How can I make symvar to not return 't'?
I use this: syms t
but no success.

採用された回答

Paulo Silva
Paulo Silva 2011 年 6 月 7 日
symvar gives you the symbolic variables inside one expression, you say that t is symbolic so the expression symvar('cos(2*pi*t)') gives you t, I can't imagine why you don't wan't to get the t.
  3 件のコメント
sadel
sadel 2011 年 6 月 7 日
If I could make symvar to identify the symbol 't' and doesn't return it then I could create
a function which evaluate only strings which represent only mathematical functions
t=0:0.1:10;
insertfunction='cos(2*pi*t))'
gh=symvar(insertfunction)
if (gh is an empty cell array)
eval(['v =0*t+ ',vectorize(gh),';'])
plot(t,v)
end
Paulo Silva
Paulo Silva 2011 年 6 月 9 日
t=0:0.1:10;
insertfunction='cos(2*pi*t))'
gh=symvar(insertfunction)
if (numel(gh)==1) %see if there's only one symbolic variable (just the t)
eval(['v =0*t+ ',vectorize(gh),';'])
plot(t,v)
end

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by