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

2 ビュー (過去 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 Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by