Having issues plotting and coloring Limacon

조회 수: 3 (최근 30일)
Nicholas Cassano
Nicholas Cassano 2019년 1월 29일
답변: Star Strider 2019년 1월 29일
This is the problem im having an issue with: PLEASE DO NOT GIVE OR DO THE PROBLEM FOR US
"the curve given in polar coordinates by r = 1 − 2 sin θ. This curve has an inner loop and an outer loop. Plot the inner loop in green and the outer loop in magenta. You may not use Matlab’s commands polar or polarplot or anything similar. "
we would like to know how to find the equation for just the inner loop and not the entire loop that includes both the inner and outer parts, and any hints on how you would personally go about coloring the different sections
what we have rn, its ugly we know;
th = 0 : pi/100 : 2*pi;
th2 = pi/6 : pi/100: 5*pi/5.91;
r = 1 - 2*sin(th);
x_3 = r.*cos(th);
y_3 = r.*sin(th);
r2 = 1 - 2*sin(th2);
x_4 = r.*cos(th2);
y_4 = r.*sin(th2);
figure()
plot(x_3, y_3, 'm')
hold on
plot(x_4, y_4, 'g')
xlabel('X = r*cos(\theta)');
ylabel('Y = r*sin(\theta)');
title('Plot of r = 1 - 2*sin(\theta)');
grid on
One of the problems we found, is while it looks right, the graphs arent producing the same curve.
Thank you any hints and input is appreciated.

답변 (1개)

Star Strider
Star Strider 2019년 1월 29일
You already have most of it done, and correctly, so congratulations!
You need to keep the ‘r’ and ‘th’ calculations together, as well as the ‘r2’ and ‘th2’ calculations, because ‘th’ and ‘th2’ are different lengths, so mixing them will cause problems:
r = 1 - 2*sin(th);
x_3 = r.*cos(th);
y_3 = r.*sin(th);
r2 = 1 - 2*sin(th2);
x_4 = r2.*cos(th2);
y_4 = r2.*sin(th2);
The only hint you need otherwise is to duplicate your two plot calls, although instead of using plot in the duplicates, use the fill (link) function, so:
plot(a,b,,'r')
fill(a,b,'r')
for each.

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by