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

2 次查看(过去 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!

采纳的回答

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 个评论
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

产品


版本

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by