フィルターのクリア

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

7 ビュー (過去 30 日間)
Dev Chhatbar
Dev Chhatbar 2022 年 12 月 17 日
コメント済み: Image Analyst 2022 年 12 月 18 日
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 Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by