Each data point plots as individual points not as one set of many points
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Abraham Cisneros
am 24 Nov. 2021
Kommentiert: Abraham Cisneros
am 28 Nov. 2021
I'm plotting data from a video file, the plot looks as it should, however, I would like to run findpeaks function to locate local maxima throughout the plot. But since each data point is its own individual element, findpeaks or curve fitting does not work. How can I combine all the data points into one set? I attached a screenshot of how the data is currently plotting .
obj = VideoReader('VidName.avi') %same name as file you create in step 1
video = read(obj);
for i=1:150 %number of frames of the video i am analyzing
avrgG(i)=mean2(video(400:420,580:600,2,i)); %color channel im plotting
plot(i,avrgG(i),'ko') %plot the channel you want
title('Green Channel Intensity Plot');
xlabel('Number of Frames');
ylabel('Intensity of Green Channel (counts)');
hold on
pause(.2)
end
0 Kommentare
Akzeptierte Antwort
Kevin Holly
am 24 Nov. 2021
Bearbeitet: Kevin Holly
am 24 Nov. 2021
obj = VideoReader('VidName.avi') %same name as file you create in step 1
video = read(obj);
for i=1:150 %number of frames of the video i am analyzing
avrgG(i)=mean2(video(400:420,580:600,2,i)); %color channel im plotting
end
plot(1:150,avrgG,'ko') %plot the channel you want
title('Green Channel Intensity Plot');
xlabel('Number of Frames');
ylabel('Intensity of Green Channel (counts)');
If you still want to see a data point added during for loop:
obj = VideoReader('VidName.avi') %same name as file you create in step 1
video = read(obj);
avrgG(1)=mean2(video(400:420,580:600,2,1)); %color channel im plotting
p = plot(1,avrgG(1),'ko') %plot the channel you want
title('Green Channel Intensity Plot');
xlabel('Number of Frames');
ylabel('Intensity of Green Channel (counts)');
for i=2:150 %number of frames of the video i am analyzing
avrgG(i)=mean2(video(400:420,580:600,2,i)); %color channel im plotting
p.XData = [p.XData i];
p.YData = [p.YData avrgG(i)];
pause(.2)
end
Weitere Antworten (1)
Yongjian Feng
am 24 Nov. 2021
plot can take arrays as inputs.
So take the plot call out of the for loop.
obj = VideoReader('VidName.avi') %same name as file you create in step 1
video = read(obj);
for i=1:150 %number of frames of the video i am analyzing
avrgG(i)=mean2(video(400:420,580:600,2,i)); %color channel im plotting
pause(.2) % MIGHT NOT NEED THIS.
end
x = 1:150;
plot(x,avrgG,'ko') %plot the channel you want
title('Green Channel Intensity Plot');
xlabel('Number of Frames');
ylabel('Intensity of Green Channel (counts)');
Siehe auch
Kategorien
Mehr zu National Instruments Frame Grabbers finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!