How to type sin function with square

112 次查看(过去 30 天)
I'm working with O.D.E in matlan and I found that I cannot type sin square x. Is there any particular syntax for that or is there any other way?

采纳的回答

Sam Chak
Sam Chak 2023-11-20
@John Sanjai J, are you expecting this?
syms x
expr = sin(x)^2
expr = 
  5 个评论
Sam Chak
Sam Chak 2023-11-21
The expression sin(x)^2 is equivalent to the mathematical notation , if I have interpreted your syntax 'sin square x' correctly. However, if there is any misunderstanding, please provide the proper mathematical notation using LaTeX to avoid ambiguity.
Walter Roberson
Walter Roberson 2023-11-21
syms x
char(sin(x)^2)
ans = 'sin(x)^2'
char(sin(x)*sin(x))
ans = 'sin(x)^2'
char(sin(x^2))
ans = 'sin(x^2)'
char(sin(x * x))
ans = 'sin(x^2)'

请先登录,再进行评论。

更多回答(1 个)

Steven Lord
Steven Lord 2023-11-21
While the usual mathematical notation to compute the square of the sine of x is , the MATLAB code to perform that computation is sin(x)^2 (or, since you likely want to compute the square of the sine element-wise, sin(x).^2).
x = 0:pi/4:2*pi
x = 1×9
0 0.7854 1.5708 2.3562 3.1416 3.9270 4.7124 5.4978 6.2832
sin(x).^2
ans = 1×9
0 0.5000 1.0000 0.5000 0.0000 0.5000 1.0000 0.5000 0.0000
You cannot put the squaring operator between the name of the function (sin) and its input argument x.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by