Matlab Plot (axes) reset not working; traces new images on the old axis

1 次查看(过去 30 天)
I'm relatively new to Matlab guide UI tool.
Here is what I'm doing:
I created a multi-tab window wherein the number of tabs depend on the number of files chosen beforehand using a 'Browse' button (e.g, 5 files chosen leads to 5 tabs, etc.). Once the files are chosen, they are plotted using imagesc() on specific tabs. I then perform a zoom on specific zones of said images using a zoom button and subsequently save these files for further processing.
Code to dynamically create tabs:
function browsebutton_Callback(hObject, eventdata, handles)
global tabgp tab fullFilename ax two_D_data time_axis;
[file_names, folder] = uigetfile( ...
{'*.ASC; *.BIN', 'All data files (*.DZT, *.ASC, *.BIN)';
'*.ASC','ASCII files (*.ASC)'; ...
'*.BIN','Binary files (*.BIN)'; }, 'Pick a file', 'Multiselect', 'On');
fullFilename = fullfile(folder, file_names);
numfiles = size(file_names,2);
for k = 1 : numfiles
[image_file, time_axis, dist] = import_images(char(fullFilename(k)));
tab(k) = uitab('Parent', tabgp, 'Title',char(file_names(k)));
ax(k) = axes('Parent', tab(k));
imagesc(ax(k), 'CData', image_file, 'YData', time_axis, 'XData', dist);
xlabel(ax(k), 'Distance axis');
ylabel(ax(k), 'Time axis');
xlim([0.5 size(image_file,2)+0.5]);
ylim([min(time_axis) max(time_axis)]);
end
end
Code to update images on an active tab:
function zoombutton_Callback(hObject, eventdata, handles)
global ax tabgp tab time_axis fullFilename;
tabNumber = find(tabgp.SelectedTab == tab);
set(handles.text6, 'String', ['Calibrating data from Panel: ' num2str(tabNumber)]);
[image_file, time_axis, dist] = import_images(char(fullFilename(tabNumber)));
[max_val, min_val, idx1, idx2] = get_minmax_vals();
new_data = image_file(idx1:idx2,:);
ax(tabNumber) = axes('Parent', tab(tabNumber));
cla(ax(tabNumber), 'reset'); % Reset isn't working
imagesc(ax(tabNumber), 'CData', new_data, 'YData', time_axis(idx1:idx2));
set(ax(tabNumber), 'YDir', 'reverse');
xlabel(ax(tabNumber), 'Distance axis');
ylabel(ax(tabNumber), 'Time (s)');
xlim([0.5 size(new_data,2)+0.5]);
ylim([min(time_axis(idx1:idx2)) max(time_axis(idx1:idx2))]);
hold(ax(tabNumber), 'off');
Issue faced:
When I perform the Zoom, the images are zoomed. However, the ticks from the previous figure are not erased.
The new image, its axis labels and ticks overlap on the old image axis labels and ticks.
Am I doing something wrong here?
PS: I'm using Matlab R2016a

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Exploration 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by