Error trying to plot circle

4 views (last 30 days)
Jenny Andersen
Jenny Andersen on 5 Dec 2019
Answered: Star Strider on 5 Dec 2019
Hi I am trying to plot a circle but I alsways get the same error "
Error in circle (line 11) a = r.*cos(v)+j;
Can you see why?
My script:
A = [10 8 2; 10 8 1; -2 9 1; 2 -1 1]
B = [50; 60; 26; 2]
M = A.' * A;
d = A.' * B;
x = A\B;
j = 2.3102
o = 2.8380
r = x.'
v = 0:pi/100:2*pi;
a = r.*cos(v)+j;
b = r.*sin(v)+o;
plot(a,b)

Accepted Answer

Star Strider
Star Strider on 5 Dec 2019
You apparently want to plot three different circles with different radii.
This works:
A = [10 8 2; 10 8 1; -2 9 1; 2 -1 1]
B = [50; 60; 26; 2]
M = A.' * A;
d = A.' * B;
x = A\B;
j = 2.3102
o = 2.8380
r = x.'
v = 0:pi/100:2*pi;
a = r(:)*cos(v)+j;
b = r(:)*sin(v)+o;
figure
plot(a.',b.')
axis equal
The transpositions in the plot call are necessary. Otherwise you get a ‘starburst’ effect that while interesting, is not what you indicated that you want.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!