Matlab - 使用GUI

时间:2016-06-22 19:32:07

标签: matlab user-interface multidimensional-array matlab-figure slice

我想使用滑块(GUI)刷新我的图形(3D,使用matlab切片命令获得)来更新切片位置。

这是我创建图形的代码(它有效):

% Create figure

Fig_3dview = figure;
Fig_3dview.Name= 'Microstructure viewer';

% hold on;
% The data to be displayed are within "Volume", a n*m*k matrix
Domain_size = size(Volume)

% Initial position of the slices
% Basically, the 6 faces of the volume
xslice = [1,Domain_size(1)]; 
yslice = [1,Domain_size(2)];
zslice = [1,Domain_size(3)]; 

% Display all the slices
imslice = slice(Volume,xslice,yslice,zslice,'parent',Fig_3dview);

% Remove voxel edge
set(imslice,'edgecolor','none')

% Current axis label
ax_3d_slice = gca;

% Set axis equal and tight
axis equal tight

hold off;

GUI的代码,用于控制切片位置(它不起作用):

% Create GUI figure
Fig_3dview_GUI = figure;
Fig_3dview_GUI.Name= 'Microstructure viewer 3D GUI';

% Create slider    
    h_slice1 = uicontrol('Style','slider','BackgroundColor','w',...
        'Unit','pixels','Position',[10,200,250,50],'Parent',Fig_3dview_GUI,...
        'Callback',{@slider_slice1_Callback});

% Define function associated with h_slice1 
    function slider_slice1_Callback(source,eventdata)
        % Determine the selected data set.
        pos_normalized = source.Value;
        position_slice_1= round(pos_normalized*Domain_size(1)); % Get closest integer value
        position_slice_1=max(1,position_slice_1); % 0 must be avoided

% Update figure

在这里,我不知道如何用第一个方向的切片的新位置更新图形Fig_3dview。 我想新的数字看起来像:

xslice = [position_slice_1,Domain_size(1)];
imslice = slice(Volume,xslice,yslice,zslice,'parent',Fig_3dview);  

我不想关闭图形并重新生成它,我想刷新它,以便我获得平滑的可视化。

        % Update figure
    end

感谢您的任何建议。 弗朗索瓦

0 个答案:

没有答案