What's the difference between sin(t) and square(t)?

2 ビュー (過去 30 日間)
Kyungsik Shin
Kyungsik Shin 2018 年 12 月 29 日
コメント済み: Kyungsik Shin 2018 年 12 月 29 日
If I code like
signal1 = sin(t);
signal1 = square(t);
then
The first one is valid but the second one is invalid showing 'Input arguments must be 'double'.'
It looks like same as built-in functions but the usages is different
What's the difference between those as the usages??

採用された回答

John D'Errico
John D'Errico 2018 年 12 月 29 日
編集済み: John D'Errico 2018 年 12 月 29 日
Let me guess. You have defined t to be a symbolic variable?
You can verify that using the whos command. Thus, if I do this:
syms t
whos t
Name Size Bytes Class Attribute
t 1x1 8 sym
So t is symbolic, as you see above.
I can use sin(t), because the symbolic toolbox can work with the sin function. However, square is a function from the signal processing toolbox. It REQUIRES double precision inputs. Therefore, you get an error message.
Not all functions are defined for symbolic input.
  1 件のコメント
Kyungsik Shin
Kyungsik Shin 2018 年 12 月 29 日
Thanks a lot
It was the matter of declaration of the functions!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Variables, Expressions, Functions, and Preferences についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by