how to solve and plot complex equation

조회 수: 6 (최근 30일)
Heather
Heather 2024년 2월 12일
편집: Walter Roberson 2024년 2월 12일
Trying to plot the bottom equation where x is 0-180 degrees. I believe the sin within the [] of the sin is where I'm messing up.
a=(b*Pi*sin(x))/c
b and c are constants
x=0-180 degrees
y=(sin^2(a))/a^2

채택된 답변

VBBV
VBBV 2024년 2월 12일
b = 3; c = 4;
x=0:180;
a=b*pi*sin(deg2rad(x))/c;
y=(sin(a).^2)./a.^2;
plot(x,y)
  댓글 수: 1
Heather
Heather 2024년 2월 12일
Thank you for the deg2rad part!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Austin M. Weber
Austin M. Weber 2024년 2월 12일
편집: Austin M. Weber 2024년 2월 12일
A couple of things: pi needs to be lowercase and you need to use .*, ./, and .^ when doing element-wise operations on vectors or matrices. I hope this helps!
a = 2;
b = 3;
c = 4;
x=0:180;
a=(b*pi*sin(x)) ./c;
y=(sin(a).^2) ./ a.^2;
plot(x,y)
  댓글 수: 1
Heather
Heather 2024년 2월 12일
Sorry that wasn’t my exact code above, but you fixed my issue anyways. I did have the P capital and I had a missing (). Thank you so much, this is my first experience with matlab and it’s been years since I used Mathematica.

댓글을 달려면 로그인하십시오.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by