viewdir.m
% Run this script after creating a 3D plot and it will
% pop up a couple of sliders to allow changing the viewpoint.
%
% See the MATLAB function 'uicontrol'
%
% This routine is supplied without warrantee or support!
fig = gcf;
sli_azm = uicontrol(fig, 'Style', 'slider', ...
'Position', [40 10 120 20], ...
'Min', -180, 'Max', 180, 'Value', 30, ...
'Callback', [ ...
'set(azm_cur,''String'',',...
'num2str(get(sli_azm,''Val''))),',...
'set(gca,''View'',',...
'[get(sli_azm,''Val''),get(sli_elv,''Val'')])']);
sli_elv = uicontrol(fig, 'Style', 'slider', ...
'Position', [230 10 120 20], ...
'Min', -90, 'Max', 90, 'Value', 30, ...
'Callback', [ ...
'set(elv_cur,''String'',',...
'num2str(get(sli_elv,''Val''))),',...
'set(gca,''View'',',...
'[get(sli_azm,''Val''),get(sli_elv,''Val'')])']);
azm_min = uicontrol(fig,...
'Style', 'text', ...
'Pos', [10 10 30 20], ...
'BackGroundColor',[0 1 0],...
'String', num2str(get(sli_azm, 'Min')));
elv_min = uicontrol(fig,...
'Style', 'text', ...
'Pos', [200 10 30 20], ...
'BackGroundColor',[0 1 1],...
'String', num2str(get(sli_elv, 'Min')));
azm_max = uicontrol(fig,...
'Style', 'text', ...
'Pos', [160 10 30 20], ...
'BackGroundColor',[0 1 0],...
'String', num2str(get(sli_azm, 'Max')));
elv_max = uicontrol(fig,...
'Style', 'text', ...
'Pos', [350 10 30 20], ...
'BackGroundColor',[0 1 1],...
'String', num2str(get(sli_elv, 'Max')));
azm_label = uicontrol(fig, ...
'Style', 'text', ...
'Pos', [40 40 65 20], ...
'BackGroundColor',[0 1 0],...
'String', 'Azimuth');
elv_label = uicontrol(fig, ...
'Style', 'text', ...
'Pos', [230 40 65 20], ...
'BackGroundColor',[0 1 1],...
'String', 'Elevation');
azm_cur = uicontrol(fig, ...
'Style', 'text', ...
'Pos', [110 40 50 20], ...
'BackGroundColor',[0 1 0],...
'String', num2str(get(sli_azm, 'Value')));
elv_cur = uicontrol(fig, ...
'Style', 'text', ...
'Pos', [300 40 50 20], ...
'BackGroundColor',[0 1 1],...
'String', num2str(get(sli_elv, 'Value')));