Show temperature differences in a dataset

조회 수: 1 (최근 30일)
Cliff Karlsson
Cliff Karlsson 2018년 10월 23일
편집: jonas 2018년 10월 26일
I have a data-set with 360*512*237 temperature readings. The actual readings is 360*512 and there are 237 readings.
I want to visualize in some nice way using a slider or other method where the temperatures fluctuate the most for example. Can anyone tell me different methods for visualizing this data.
This is the code I got for now:
if exist('matrix_values_year.mat', 'file') == 2
load('matrix_values_year.mat');
else
file = dir('data\\year\\*.OTT');
measure_matrix = [];
for i = 1:size(file, 1)
if file(i).bytes <= 2000 | file(i).bytes > 70000 ;
measure_matrix = cat(3,measure_matrix,measure_matrix(:,:,i-1));
else
filnamn = string(strcat(file(i).folder,{'\'},file(i).name));
measure_matrix = cat(3,measure_matrix,getHeatMap(filnamn));
end
end
save matrix_values_year.mat measure_matrix;
end
max_difference = 0
measure_matrix = rescale(measure_matrix,50,450, 'InputMin', 0,'InputMax',255);
column_matrix = zeros(512,237);
x=0;
y=0;
for i=1:237
for j=1:512
differance = (max(measure_matrix(:,j,i)) - min(measure_matrix(:,j,i)));
column_matrix(j,i) = differance;
if( differance > max_difference )
max_difference = differance;
x=i;
y = j;
end
end
end
sample = measure_matrix(:,:,50);
figure
h= histogram(column_matrix)
figure
mesh(column_matrix')
view(-15,20)
function heat = getHeatMap(filename_s)
s = dir(filename_s);
fin=fopen(filename_s,'r');
I=fread(fin,s.bytes,'uint8=>uint8');
fclose(fin);
w = uint16(I(1))+256*uint16(I(2));
h = uint16(I(3))+256*uint16(I(4));
skip = s.bytes - w*h + 1;
IN = I(skip:1:s.bytes);
Z=single(reshape(IN,w,h));
Z=griddedInterpolant(Z');
y_range = linspace(1.0,single(h),360);
x_range = linspace(1.0,single(w),512);
heat = uint8(Z({y_range, x_range}));
end
  댓글 수: 2
jonas
jonas 2018년 10월 23일
편집: jonas 2018년 10월 23일
What does the row/column index represent? Spatial location? What do you mean fluctuate the most? Biggest difference between min and max value?
Cliff Karlsson
Cliff Karlsson 2018년 10월 24일
Yes correct, the row/columns represent an area with different temperature readings. I want to be able to maybe use some sort of slider to be able to compare different reading to eachother.

댓글을 달려면 로그인하십시오.

채택된 답변

jonas
jonas 2018년 10월 23일
편집: jonas 2018년 10월 26일
Here you can see the difference between minimum and maximum taken over the 3rd dimension, which I can only assume is time?
data = load('matrix_values_year.mat');
A = data.measure_matrix;
Ad = max(A,[],3) - min(A,[],3);
surf(Ad,'edgecolor','none')
view([0 90])
axis tight
set(gca,'layer','top')
colorbar
You probably want to use some variety of surface plot. There are several types, such as contourf, pcolor, imagesc, mesh, imshow etc...
Slider option (code adapted from OP's 'answer')
data = load('matrix_values_year.mat');
B = data.measure_matrix;
FigH = figure('position',[360 500 400 400]);
axes('XLim', [0 512],'units','pixels', ...
'position',[100 50 200 200], 'NextPlot', 'add'); hold on
cb = colorbar(gca)
cb.Limits= [0 100]
set(gca,'CLim',[0 100])
im = mesh(B(:,:,1));
axis tight
set(gca,'ZLim',[0 100]);
TextH = uicontrol('style','text',...
'position',[170 340 40 15]);
SliderH = uicontrol('style','slider','position',[100 280 200 20],...
'Value',1,'min', 1, 'max', 237,'callback',{@callbackfn,B,im});
function callbackfn(source, eventdata,B,im)
num = eventdata.Source.Value;
im.CData = B(:,:,round(num));
im.ZData = B(:,:,round(num));
set(gca,'ZLim',[0 100])
end

추가 답변 (1개)

Cliff Karlsson
Cliff Karlsson 2018년 10월 24일
I tried to understand how to add a slider, but the image does not update when I move the slider. What am I doing wrong?
function sliderfun
data = load('matrix_values_year.mat');
B = data.measure_matrix;
FigH = figure('position',[360 500 400 400]);
axes('XLim', [0 512], 'units','pixels', ...
'position',[100 50 200 200], 'NextPlot', 'add');
im = mesh(B(:,:,1));
TextH = uicontrol('style','text',...
'position',[170 340 40 15]);
SliderH = uicontrol('style','slider','position',[100 280 200 20],...
'min', 0, 'max', 237);
addlistener(SliderH, 'Value', 'PostSet', @callbackfn);
movegui(FigH, 'center')
function callbackfn(source, eventdata)
num = get(eventdata.AffectedObject, 'Value');
im = B(:,:,round(num));
end
end
  댓글 수: 3
Cliff Karlsson
Cliff Karlsson 2018년 10월 26일
편집: Cliff Karlsson 2018년 10월 26일
Thanks for the answer. But I have one problem, if I rotate the figure so that I also see the elevation of the plot, only the colors update on each click not the actual shape of the plot.
jonas
jonas 2018년 10월 26일
I've updated the script.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by