Borrar filtros
Borrar filtros

How do I draw circles in App Designer with user inputting the x, y and radii values?

7 visualizaciones (últimos 30 días)
Hi,
So i am creating a project where I need to be able to draw multiple circles with different x, y and radii values. I was able to make one circle but it had a fixed radius and I would like it to be such that the user can input the different values and that is then used to plot the circle. This is what I have written down so far. I would appreciate any help I can get!
clear;
r = 4;
caca = 2*pi;
ang = linspace(0,caca);
xp = r*cos(ang);
yp = r*sin(ang);
circ = [xp;yp];
figure(1)
plot(xp,yp)
I tried writing:
r = inputdlg;
but it just wouldn't work. I mean it would allow the user to input the value but wouldn't plot a circle.
Any ideas on how I can get the user to enter the x, y and radii values and have it plot perfectly on a graph. I also want it to plot multiple circles.
Thank you!

Respuestas (1)

VBBV
VBBV el 17 de Dic. de 2022
In the app designer, you can invoke the follwing code,
% in the app designer
prompt = {'Enter radius of circle:', 'Enter centre:'}
T_L = 'Circle'
dims = [1 40]
out = inputdlg(prompt,T_L,dims)
caca = 2*pi;
ang = linspace(0,caca);
r = str2num(out{1});
C = str2num(out{2});
xp = C(1)*cos(ang);
yp = C(2)*sin(ang);
plot(xp,yp,'r-')
  11 comentarios
Dev Chhatbar
Dev Chhatbar el 17 de Dic. de 2022
Editada: Dev Chhatbar el 17 de Dic. de 2022
@Image Analyst- Yes! That's a good point. I wonder why I didn't change that. You're right. Those are three things my user would need to enter. And based off of that, I'm meant to apply those inputs and plot the circles and then find the intersection point and draw tangential lines!
Image Analyst
Image Analyst el 18 de Dic. de 2022
I believe I fixed it for you in your duplicate question.

Iniciar sesión para comentar.

Categorías

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

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by