how do i write sin^2(x) in matlab?
古いコメントを表示
I am trying to plot sin^2(x) together with cos^2(x) between [0,2pi]
but cant get my matlab to accept sin^2(x).
here is what I wrote, what am i doing wrong?
x=0:0.01:2*pi
si=sin^2(x);
co=cos^2(x);
plot(si,co)
5 件のコメント
manoj pokhriyal
2020 年 9 月 4 日
si=(sin(x))^.2
co=(cos(x))^.2
plot(si,co)
manoj pokhriyal
2020 年 9 月 4 日
sorry my mistake
si=sin(x).^2
co=cos(x).^2
plot(si,co)
Hammad
2024 年 1 月 23 日
移動済み: Dyuman Joshi
2024 年 1 月 23 日
how sin(-5) is equal to 0.9589 in matlab?
That is the correct value for the sine of -5 radians. If you wanted to compute the sine of -5 degrees use the sind function instead of the sin function.
R1 = -5; % radians
D1 = rad2deg(R1) % -5 radians in degrees
sineOfMinus5Radians = [sin(R1); sind(D1)]
D2 = -5; % degrees
R2 = deg2rad(D2) % -5 degrees in radians
sineOfMinus5Degrees = [sind(D2); sin(R2)]
Dyuman Joshi
2024 年 1 月 23 日
編集済み: Dyuman Joshi
2024 年 1 月 23 日
@Hammad, the input of sin() is considered as radian, which can be seen from the documentation of sin (easily foundable by a simple search on the internet), thus the value is provided accordingly.
Also note that the output shown is a truncated value upto 4 digits after decimal, which is not what the actual value is.
採用された回答
その他の回答 (1 件)
hemin ahmad
2024 年 2 月 18 日
0 投票
sin(x)
1 件のコメント
Walter Roberson
2024 年 2 月 18 日
No, this is not correct. As explained above, sin(x).^2 is needed.
カテゴリ
ヘルプ センター および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
