Problem with imagesc in GUI

3 次查看(过去 30 天)
Antti
Antti 2013-11-12
评论: Antti 2013-11-12
Hello,
I have a GUI where I import thermal camera data from files and then plot it in the GUI. I have two types of files: xls-data and csv-data. Xls-data is working fine, but when using csv-data, my axes are not set correctly. For example, if the length of the data is 43.2 meters, in GUI the length of x-axis is only 43 meters. And same problem with the y-axis. Any idea how to handle axes properties? The problem is not because of the datatypes (xls,csv, etc.) as I have tried to import data in several ways. However, the problem seems to be related with handling the axes properties of a GUI.
function import_button_Callback(hObject, eventdata, handles)
if handles.datatype == 1
data = dlmread(file, '\t',11,0);
else
data = xlsread(file, -1);
end
length_data = length(data(:,1))*2.5/100; %Pixel-size is 0.025m
width_data = length(data(1,:))*2.5/100; %Pixel-size is 0.025m
data(data<=80)=NaN; %temperature limit set to 80C
clims = [80 160];
gca =handles.image;
handles.image = imagesc(0:length_data, 0:width_data, data',clims);
colorbar;
guidata(hObject, handles);
I was also thinking to set labels manually ('XTickLabel' and 'YTickLabel'), but as I need to draw rectangle (using imrect) in the figure and show/get coordinates, that's not really helping.

回答(1 个)

Image Analyst
Image Analyst 2013-11-12
You can use xlim() to set the limits of the x axis to start and stop at whatever values you want rather than have it automatically decide.
  1 个评论
Antti
Antti 2013-11-12
Thanks for the quick answer, but I think I didn't express my problem very well.
Consider a situation, where you have a matrix with a size of 4000x320. Your pixel size is 0.025x0.025m. So, you have data with length of 100 meters and width of 8 meters.
My question is how do you plot the data into the figure so that x-axis goes from 0 to 100 and y-axis goes from 0 to 8m? If I set xlim [0 100] and ylim [0 8] that doesn't work.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by