How to use the slider tool from a GUI to slide through different graphs on the same axes?

1 view (last 30 days)
I currently have a for loop that plots certain points on my graph, saves this graph as an image, and then moves on to the second, and third all the way to 30. So right now I have 30 image files that are being saved in my folder. I want to be able to use the slider tool so I can accordingly view one of these specific images on the axes in my GUI.
I don't quite understand how to really use the slider tool using a GUI (I have been looking online but I can't really understand how) and was hoping for some help as to how I should code this.
Here is the code I have right now:
function TalarachSlices_Callback(hObject, eventdata, handles)
% hObject handle to TalarachSlices (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%%Set axes limits--These values are consistent with Talairach atlases of the Thalamus
ThalamicNuclei = evalin('base','ThalamicNuclei_CL_Talairach');
PatientID = evalin('base','PatientID');
Xmin = 0; Xmax = 30;
Ymin = -25; Ymax = 10;
Zmin = -10; Zmax = 20;
Numberofclusters = length(ThalamicNuclei);
%%The first loop creates the figure. This could potentially be commented out if a figure already exists
axes(handles.SagittalSlice), hold;
for i = 1:Numberofclusters
%Plot all nuclei
tri = trisurf(ThalamicNuclei(i).Delaunay, ThalamicNuclei(i).SmallXCoordinates, ThalamicNuclei(i).SmallYCoordinates, ThalamicNuclei(i).SmallZCoordinates);
set(tri, 'FaceColor', ThalamicNuclei(i,1).Color, 'EdgeColor', 'none') %'EdgeColor','none' gets rid of the annoying black lines!
end
%Label the plot
xlabel('X (mm)'), ylabel('Y (mm) '), zlabel('Z (mm)')
%%Generate Sagittal Slices
view(90,0)
for Xslice = Xmin:1:Xmax
axis([Xslice,(Xslice+.1),Ymin,Ymax,Zmin,Zmax])
filename = [num2str(PatientID) '_Sagittal_',num2str(Xslice),'mm', '.png']; %look into the resolution necessary for publication
saveas(gcf, filename)
end
Basically I have a push button that generates these images on my axes in my GUI and saves them 1 by 1 in my folder.
Any help would be greatly appreciated.

Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!