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일

0 개 추천

@John Sanjai J, are you expecting this?
syms x
expr = sin(x)^2
expr = 

댓글 수: 5

John Sanjai  J
John Sanjai J 2023년 11월 20일
편집: John Sanjai J 2023년 11월 20일
is equivalent to sin^2 *( x ) or sin(x^2)
Sam Chak
Sam Chak 2023년 11월 20일
편집: Sam Chak 2023년 11월 21일
If you want to be safe then use parenthesis:
syms x
expr = (sin(x))^2
expr = 
sin(pi/4)^2 % should return (1/√2)² = 1/2
ans = 0.5000
John Sanjai  J
John Sanjai J 2023년 11월 21일
please read the question carefully. It's not what I meant
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.
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일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2023년 11월 20일

답변:

2023년 11월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by