How can I get Matlab to display a warning when one of the temperatures is greater than 2x the other?

조회 수: 1 (최근 30일)
The code below opens an infra-red (.SEQ) file and plots the temperature at a point for each frame. I was wondering how I could get Matlab to display a warning when tempInsulator is more than twice as much as the tempAmbient. It would also be nice to plot both temperatures on the same graph. Thanks.
%##### Load image #####
videoFileName='file';
% Load the Atlas SDK
atPath = getenv('FLIR_Atlas_MATLAB');
atImage = strcat(atPath,'Flir.Atlas.Image.dll');
asmInfo = NET.addAssembly(atImage);
%open the IR-file
file = Flir.Atlas.Image.ThermalImageFile(videoFileName);
seq = file.ThermalSequencePlayer();
%Get the pixels
img = seq.ThermalImage.ImageProcessing.GetPixelsArray;
im = double(img);
figure(1)
imshow(im,[])
figure(2)
%get the temperature of the insulator
h = plot(1:1:seq.Count,seq.ThermalImage.GetValueFromSignal(im(165,143)));
title('Temp (C) of the Insulator')
ylabel('Temperature (C)')
xlabel('Frame')
if(seq.Count > 1)
%pre allocate
tempAmbient = NaN * ones(seq.Count,1);
tempInsulator = NaN * ones(seq.Count,1);
while(seq.Next())
img = seq.ThermalImage.ImageProcessing.GetPixelsArray;
im = double(img);
%get the erature of the insulator and background
tempAmbient(seq.SelectedIndex) = seq.ThermalImage.GetValueFromSignal(im(165,100));
tempInsulator(seq.SelectedIndex) = seq.ThermalImage.GetValueFromSignal(im(165,143));
%plot temp vs frames
set(h,'XData',1:1:seq.Count)
set(h,'YData',tempInsulator)
figure(1)
imshow(im,[]);
drawnow;
end
figure(3)
%temp vs time plot
count1 = timeseries(tempInsulator(:,1),[0:(double(1)/double(seq.FrameRate)):(double(seq.Count)/double(seq.FrameRate) - 1/double(seq.FrameRate))]);
count1.Name = ' Temp (C) of the Insulator';
count1.TimeInfo.Units = 'Sec';
plot(count1,':b')
end

채택된 답변

Eric
Eric 2017년 11월 1일
It depends how you would like it to display. Check out the documentation for warning(), warndlg(), etc. If you want to display the warning on the graph, that will involve text objects and that sort of thing.
To plot on the same graph, use 'hold on' after the first call to plot() or else plot them all in the same call, e.g. plot(x1,y1,x2,y2,...).
  댓글 수: 8
Nathan B
Nathan B 2017년 11월 2일
편집: Nathan B 2017년 11월 2일
Whenever I try to add a second plot I start to get an error in the line below. For example, I left everything the same but added a h2 = plot(...) below the first one (h = plot(...) ) and got the error in that line even though h2 wasn't used after that. If I put the h2 = plot(...) above the h = plot(...) it runs as it normally would.
set(h,'XData',1:1:seq.Count)
Error:
Error using matlab.graphics.chart.primitive.Line/set
Invalid or deleted object.
Eric
Eric 2017년 11월 4일
You need to set “hold on” before the second call to plot to keep it from deleting the first line.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by