MATLAB Answers

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

2 ビュー (過去 30 日間)
Sergey Kasyanov
Sergey Kasyanov 2018 年 8 月 17 日
コメント済み: Fangjun Jiang 2018 年 8 月 17 日
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 件のコメント

Stephen Cobeldick
Stephen Cobeldick 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 日
Thanks. Link help me to find solution.

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

採用された回答

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.

  0 件のコメント

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

その他の回答 (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 日
Or you want to run this, but want the result to be 1?
>> s=str2sym([{'2*x'},{'2*x+1'}])
s =
[ 2*x, 2*x + 1]
>> diff(s)
ans =
[ 2, 2]
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