登录论坛

查看完整版本 : 为何htext1和hpopup1在窗口最大化后位置不对齐?


未注册
2008-04-18, 09:55
为何htext1和hpopup1在窗口最大化后位置不对齐?

align([bbstart,htext,hpopup,htext1,hpopup1],'none','top');

这句不起作用?

原码如下:

function simple_gui2
% SIMPLE_GUI2 Select a data set from the pop-up menu, then
% click one of the plot-type push buttons. Clicking the button
% plots the selected data in the axes.
%---------------------------------------------------------------------------------------------------
% Create and then hide the GUI as it is being constructed.
f = figure('Visible','off','Position',[360,500,450,285]);
set(gcf,'Color',[1,1,1])
% Construct the components.


ha = axes('Units','Pixels','Position',[30,70,400,200]); %the chart



bbstart = uicontrol('Style','pushbutton','String','START',...
'Position',[370,10,70,20],...
'Callback',{@bbstartbutton_Callback});



htext = uicontrol('Style','text','String','Sample Size',...
'Position',[170,16,60,10]);



hpopup = uicontrol('Style','popupmenu',...
'String',{'10000','8000','6000','4000','2000','1000','800','400','200','100'},...
'Position',[240,10,60,10],...
'Callback',{@popup_menu_Callback});




htext1 = uicontrol('Style','text','String','Com Speed',...
'Position',[10,16,60,10]);



hpopup1 = uicontrol('Style','popupmenu',...
'String',{'115200','19200','9600','4800','2400','1200','600','300'},...
'Position',[80,10,60,10],...
'Callback',{@popup1_menu_Callback});



align([bbstart,htext,hpopup,htext1,hpopup1],'none','top');


% Initialize the GUI.
% Change units to normalized so components resize
% automatically.
set([f,ha,bbstart,htext,hpopup],...
'Units','normalized');
%Create a plot in the axes.
current_data = 10000;
current_data1 = 115200;
% Assign the GUI a name to appear in the window title.
set(f,'Name','RF ADC')
% Move the GUI to the center of the screen.
movegui(f,'center')
% Make the GUI visible.
set(f,'Visible','on');

% Callbacks for simple_gui. These callbacks automatically
% have access to component handles and initialized data
% because they are nested at a lower level.

% Pop-up menu callback. Read the pop-up menu Value property
% to determine which item is currently displayed and make it
% the current data.


%---------------------------------------------------------------------------------------------------


function popup_menu_Callback(source,eventdata)
% Determine the selected data set.
str = get(source, 'String');
val = get(source,'Value');
% Set current data to the selected data set.

switch str{val};
case '10000' % User selects
current_data = 10000;
case '8000' % User selects
current_data = 8000;
case '6000' % User selects
current_data = 6000;
case '4000' % User selects
current_data = 4000;
case '2000' % User selects
current_data = 2000;
case '1000' % User selects
current_data = 1000;
case '800' % User selects
current_data = 800;
case '400' % User selects
current_data = 400;
case '200' % User selects
current_data = 200;
case '100' % User selects
current_data = 100;
end
end

% Push button callbacks. Each callback plots current_data in
% the specified plot type.





function popup1_menu_Callback(source,eventdata)
% Determine the selected data set.
str = get(source, 'String');
val = get(source,'Value');
% Set current data to the selected data set.

switch str{val};
case '115200' % User selects
current_data1 = 115200;
case '19200' % User selects
current_data1 = 19200;
case '9600' % User selects
current_data1 = 9600;
case '4800' % User selects
current_data1 = 4800;
case '2400' % User selects
current_data1 = 2400;
case '1200' % User selects
current_data1 = 1200;
case '600' % User selects
current_data1 = 600;
case '300' % User selects
current_data1 = 300;
end
end

% Push button callbacks. Each callback plots current_data in
% the specified plot type.







function bbstartbutton_Callback(source,eventdata)
% Display surf plot of the currently selected data.
% surf(current_data);



s=serial('com1');
fclose(s);
s.Baudrate=(current_data1);
s.Parity='none' ; % Set parity as none
s.Databits=8 ; % set the number of data bits
s.StopBits=1; % set number of stop bits as 1
s.InputBufferSize=(current_data);
s.OutputBufferSize=512;
s.FlowControl='none';
s.Timeout=20;
%s.Terminator='LF';
fopen(s);
fprintf(s,'*IDN?')
ser_data=fread(s,current_data,'uint8');

fclose(s);
delete(s);


ax=1:current_data;
plot(ax,ser_data);xlabel('DOT');ylabel('ADC Input (0 to 255)');grid;

end

%function meshbutton_Callback(source,eventdata)
% Display mesh plot of the currently selected data.
% mesh(current_data);
%end

% function contourbutton_Callback(source,eventdata)
% Display contour plot of the currently selected data.
% contour(current_data);
% end

end