help me to solve my promblem (sin)

12 Ansichten (letzte 30 Tage)
승민 한
승민 한 am 8 Apr. 2022
Beantwortet: Simar am 28 Sep. 2023
>> thetha=0:pi/100:2*pi;
>> r=sin^2(theta)+cos^2(theta)
r=sin^2(theta)+cos^2(theta)
유효하지 않은 표현식입니다. 함수를 호출하거나 변수를 인덱싱할 때는 소괄호를 사용하십시오. 그렇지 않으면, 일치하지 않는 구분
기호가 있는지 확인하십시오.
정정 제안:
>> r=sin^2*(thetha)+cos^2*(thetha)
다음 사용 중 오류가 발생함: sin
입력 인수가 부족합니다.

Antworten (1)

Simar
Simar am 28 Sep. 2023
According to my understanding and the error message, it seems there is an error in your MATLAB code. The error message suggests that you are using an invalid expression when trying to calculate r.
To fix the error, you need to use parentheses to indicate the function calls to sin and cos. Additionally, you have a typo in the variable name thetha, which should be corrected to theta.
Here's the corrected code:
theta = 0:pi/100:2*pi;
r = sin(theta).^2 + cos(theta).^2;
In this code, the sin and cos functions are called with the theta variable as the input. The (. ^) operator is used to perform element-wise squaring of the resulting values. Finally, the squared values of sin(theta) and cos(theta) are added together to calculate r.
Please note that r will be an array with the same size as theta, containing the calculated values for each angle.
I hope this helps! Let me know if you have any further questions.
Best Regards,
Simar

Kategorien

Mehr zu ThingSpeak finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!