:
function myGui(n)
if nargin == 0; n = randi(20); end
if n > 20 || n < 1
error ('myGui:n', 'The input parameter "n" (%i) is outwith the allowed range (0 to 20)', n);
end
% create the parent figure
hFig = figure;
% create the positions
locations = linspace (0.9, 0.1, n);
% loop for n to create them, in this example the callback displays the number of the button pushed.
% The buttons have a fixed height of 0.05 (normalized).
for ii=1:n
uicontrol ('parent', hFig, 'style', 'push', 'Units', 'normalized', 'Position', [0.1 locations(ii) 0.5 0.05], 'String', num2str(ii), 'Callback', @(a,b)fprintf ('Pushed %i\n', ii));
end
end
うわー。これは迅速かつ正確でした。おかげで多く、これは素晴らしい作品 – Rafael