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

1 view (last 30 days)
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

Accepted Answer

Eric
Eric on 1 Nov 2017
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 Comments
Nathan B
Nathan B on 2 Nov 2017
Edited: Nathan B on 2 Nov 2017
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!