1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| function testPlot3
x = []; %tes valeurs de X
y = []; %tes valeurs de y
quantite = []; %tes quantites pour chaque X,Y pour chaque minute
nbMinutes = 1440;
[h_graphique, slider, text] = creerFenetre(nbMinutes, x, y, quantite);
dessinerGraphe(h_graphique, slider, text, x, y, quantite);
function [h_graphique, slider, text] = creerFenetre(nbMinutes, x, y, quantite)
%Creation de la fenetre
h_figure = figure('MenuBar','none','Name','Exemple plot3 avec slider','NumberTitle','off',...
'Units','pixels','Position',[0 0 800 600],'Resize','off',...
'Tag','h_figure','Visible','on');
movegui(h_figure,'center');
%Creation des axes
h_graphique = axes('Parent', h_figure,'unit', 'pixels','Position',[60 60 680 500],'tag','graphique3D');
xlabel('X');
ylabel('Y');
zlabel('quantite');
%Creation du slider
text = uicontrol(h_figure,'style','text','string','Minutes ecoulees:','tag','lb_slider','unit', 'pixels','position', [30 10 200 20]);
slider = uicontrol(h_figure,'style','slider','min', 1, 'max', nbMinutes, 'value', 1, 'unit', 'pixels','position', [240 10 430 20],...
'tag','slider','callback', @(hObject,eventdata)dessinerGraphe(h_graphique, hObject, text, x, y, quantite));
set(slider, 'SliderStep', [0.00072 0.00072]);
function dessinerGraphe(graphique, slider, text, x, y, quantite)
minute = floor(get(slider, 'value'));
set(text, 'string', sprintf('Minutes ecoulees: %d',minute));
plot3(graphique, x, y, quantite(minute,:)); |
Partager