Multiple Input DIalog Box
3 ビュー (過去 30 日間)
古いコメントを表示
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 件)
Jose Jeremias Caballero
2012 年 1 月 2 日
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
>>
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spline Postprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!