필터 지우기
필터 지우기

How does symvar work?

조회 수: 2 (최근 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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by