Problem with imagesc in GUI

2 views (last 30 days)
Antti
Antti on 12 Nov 2013
Commented: Antti on 12 Nov 2013
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.

Answers (1)

Image Analyst
Image Analyst on 12 Nov 2013
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 Comment
Antti
Antti on 12 Nov 2013
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.

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output 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!