Problem, when trying to differentate sin(f(x)), with variable x

1 回表示 (過去 30 日間)
Andy
Andy 2014 年 4 月 26 日
コメント済み: Azzi Abdelmalek 2014 年 4 月 27 日
Hello!
I would like to try some basic functions in Matlab. I faced two problems, which seems unable to solve for me.
If I type:
a=sin(3*x)
b=diff(a,x)
Then I run it:
a=sin(3*x)(3*x)
b=3*D(sin(3*x))(3*x)
I think it should be:
a=sin(3*x)
b=3*cos(3*x)
Please tell me what is wrong with my little code! Thank you!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 26 日
syms x
a=sin(3*x)
b=diff(a,x)
The result is
b =
3*cos(3*x)

その他の回答 (5 件)

Andy
Andy 2014 年 4 月 26 日
Please look at the picture attached! You will see what my problem is. Do you have any idea what's wrong?

Andy
Andy 2014 年 4 月 26 日

Walter Roberson
Walter Roberson 2014 年 4 月 27 日
I think maybe you had something in your workspace that was interfering. Did you try clearing all variables, or restarting MATLAB?

Roberto
Roberto 2014 年 4 月 27 日
try clearing the workspace
>> clear all;

Andy
Andy 2014 年 4 月 27 日
Thank you! Clearing my workspace solved the problem.
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 27 日
Don't use clear all, just clear your variables

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

Community Treasure Hunt

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

Start Hunting!

Translated by