Each data point plots as individual points not as one set of many points
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Kevin Holly
2021년 11월 24일
편집: Kevin Holly
2021년 11월 24일
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
추가 답변 (1개)
Yongjian Feng
2021년 11월 24일
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)');
참고 항목
카테고리
Help Center 및 File Exchange에서 National Instruments Frame Grabbers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!