How can I get Matlab to display a warning when one of the temperatures is greater than 2x the other?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuesta aceptada
Eric
el 1 de Nov. de 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 comentarios
Eric
el 4 de Nov. de 2017
You need to set “hold on” before the second call to plot to keep it from deleting the first line.
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!