i cant seem to find the problem here, I am trying to plot a circle in the axes in GUI and the code only outputs lines.

1 visualización (últimos 30 días)
edit1 = str2num(get(handles.edit1, 'String')); edit3 = str2num(get(handles.edit2, 'String')); x = edit1:edit3 ; y = x.^2 - 2 ; axes(handles.axes1); plot(x,y,'-square') grid on

Respuestas (1)

Monisha Nalluru
Monisha Nalluru el 14 de Abr. de 2021
The general representation for circle is .
The above is a parabola this is reason for getting lines instead of circle.
For a circle if center,radius is given you can fimplicit function to plot.
As an example
r=2; % radius of circle
x0=0; % x center of circle
y0=0; % y center of circle
syms x y
fimplicit((x-x0).^2 + (y-y0).^2 -r^2); %plot circle
Similary you can get circle co-ordinates using and and plot them if radius, center of circle is given
r=2;
x=0;
y=0;
th = 0:pi/6:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
plot(xunit, yunit);

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by