Each data point plots as individual points not as one set of many points
1 回表示 (過去 30 日間)
古いコメントを表示
Abraham Cisneros
2021 年 11 月 24 日
コメント済み: Abraham Cisneros
2021 年 11 月 28 日
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!