필터 지우기
필터 지우기

help me to solve my promblem (sin)

조회 수: 2 (최근 30일)
승민 한
승민 한 2022년 4월 8일
답변: Simar 2023년 9월 28일
>> 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
입력 인수가 부족합니다.

답변 (1개)

Simar
Simar 2023년 9월 28일
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

카테고리

Help CenterFile Exchange에서 병렬 for 루프(parfor)에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!