How i can call matlab basic function if that name is accotiated with couple of functions?

조회 수: 1 (최근 30일)
Hello,
I need to call function diff (differences between array elements) for array of symbolic variable but matlab is using function diff from matlab symbolic math toolbox. How I can define namespace of calling function?
Thanks!
  댓글 수: 2
Stephen23
Stephen23 2018년 8월 17일
편집: Stephen23 2018년 8월 17일
"I need to call function diff..."
Why do you "need" to do this? What are you trying to achieve? So far, based on your description, the simplest and best solution to your problem is to not use this name:

댓글을 달려면 로그인하십시오.

채택된 답변

Sergey Kasyanov
Sergey Kasyanov 2018년 8월 17일
The simplest way to do that is use that code:
varargout = builtin('diff',varargin{:});
Also you can looking for something usefull there.

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2018년 8월 17일
I thought it is automatic as long as you specify your symbolic variable is properly specified.
>> diff(1:3)
ans =
1 1
>> s=str2sym('2*x')
s =
2*x
>> diff(s)
ans =
2
  댓글 수: 3
Sergey Kasyanov
Sergey Kasyanov 2018년 8월 17일
Yes, I want to take 1 as a result, but function diff is not work with symbolic arrays as i understand.
Fangjun Jiang
Fangjun Jiang 2018년 8월 17일
I guess you have to achieve it in a different way.
>> builtin('diff',s)
Error using builtin
Undefined function 'diff' for input arguments of type 'sym'.
>> builtin('diff',1:3)
ans =
1 1
>> s(2)-s(1)
ans =
1

댓글을 달려면 로그인하십시오.

제품


릴리스

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by