# how to solve and plot complex equation

2 views (last 30 days)
Heather on 12 Feb 2024
Edited: Walter Roberson on 12 Feb 2024
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 on 12 Feb 2024
b = 3; c = 4;
x=0:180;
y=(sin(a).^2)./a.^2;
plot(x,y)
Heather on 12 Feb 2024
Thank you for the deg2rad part!

Austin M. Weber on 12 Feb 2024
Edited: Austin M. Weber on 12 Feb 2024
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)
Heather on 12 Feb 2024
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.