필터 지우기
필터 지우기

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

조회 수: 7 (최근 30일)
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!

답변 (1개)

VBBV
VBBV 2022년 12월 17일
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
Dev Chhatbar
Dev Chhatbar 2022년 12월 17일
편집: Dev Chhatbar 2022년 12월 17일
@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 2022년 12월 18일
I believe I fixed it for you in your duplicate question.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by