Error trying to plot circle

2 visualizzazioni (ultimi 30 giorni)
Jenny Andersen
Jenny Andersen il 5 Dic 2019
Risposto: Star Strider il 5 Dic 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)

Risposta accettata

Star Strider
Star Strider il 5 Dic 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.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by