Azzera filtri
Azzera filtri

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

7 visualizzazioni (ultimi 30 giorni)
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!

Risposte (1)

VBBV
VBBV il 17 Dic 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 Commenti
Dev Chhatbar
Dev Chhatbar il 17 Dic 2022
Modificato: Dev Chhatbar il 17 Dic 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!

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by