how do I code sin(theta)/cos(theta)?

조회 수: 6 (최근 30일)
Mike Ahlers
Mike Ahlers 2018년 5월 25일
편집: Walter Roberson 2018년 5월 25일
I would like to create an array with values for both theta(sin^2/cos^2), so I get values for 6 input values.
x=[0.51 0.71 1.0 0.71 0 -0.71];
y=[0.87 0.71 0 -0.7 -1.0 -0.7];
sind^2 (x)
cosd^2 (y)
x+y;
I continue to getting errors to this effect.
sind^2 (x)
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

답변 (1개)

Ameer Hamza
Ameer Hamza 2018년 5월 25일
The correct way to square the function in MATLAB is as follows
sind(x).^2
apart from that, you didn't include you function handle which is causing the error. Also see the difference between element-wise multiplication and matrix multiplication in MATLAB

카테고리

Help CenterFile Exchange에서 Install Products에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by