Multiple Input DIalog Box

3 views (last 30 days)
Saptarshi Bhattacharjee
Saptarshi Bhattacharjee on 2 Jan 2012
I have a problem where I need to accept the value of a number (say n, which is incidentally the no of circles to be accepted for the problem) and depending on the value of n I need to accept 2n values into an array nx2(these will be actually the coordinates of the centers of the n circles, where each row of the matrix represents the x and y coordinate of one circle)...I want to design an input box first that will ask the user to input the value of n. Depending on the value of n entered, thereafter an input dialog should open asking for 2n center values. the dialog can be of the following form
Enter the center of 1st circle ______ _______
Enter the center of 2nd circle ______ _______
Enter the center of 3rd circle ______ _______
Enter the center of 4th circle ______ _______
Enter the center of 5th circle ______ _______
Any idea how I can design an input box for such problems??Thanks in advance
  1 Comment
Walter Roberson
Walter Roberson on 2 Jan 2012
My email address is not an acceptable Tag.

Sign in to comment.

Answers (1)

Jose Jeremias Caballero
Jose Jeremias Caballero on 2 Jan 2012
Hi.
%=======================
clear all
n=input('Enter the number of circles n:');
k=1;
while k<=n
center(k,:)=input(['Enter the center of ',num2str(k),' st circle:']);
k=k+1;
end
display(center)
x=center(:,1);
y=center(:,2);
%=============================
>> %EXECUTION
>> ncircles
Enter the number of circles n:3
Enter the center of 1st circle:[10 4]
Enter the center of 2st circle:[2 2]
Enter the center of 3st circle:[5 3]
center =
10 4
2 2
5 3
>> %EXECUTION
>> ncircles
Enter the number of circles n:5
Enter the center of 1st circle:[2 3]
Enter the center of 2st circle:[3 1]
Enter the center of 3st circle:[3 4]
Enter the center of 4st circle:[-5 6]
Enter the center of 5st circle:[10,12]
center =
2 3
3 1
3 4
-5 6
10 12
>>

Categories

Find more on Spline Postprocessing in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!