How to save a video and a graph in the same video file MatLab?

1 view (last 30 days)
I am doing an experiment where i measure the temperature of a substance and want to record the results in a video file. I want the video file to have the actual video of the experiment and the graph of the temperature in the SAME video file. I was already able to create a video file using MatLab (using videowriter)of the graph and another video file of the experiment. But I am having fusing them together in one video file. Thanks in advance. this is the code
a=arduino('COM5')% connect to arduino ai_pin= 0; tic; i=0;
vidObj = VideoWriter('experiment.avi'); open(vidObj); while toc<30 i=i+1; time(i)=toc; temp(i)=a.analogRead(ai_pin); figure(1); subplot(2,1,1); plot(time,temp,'r'); title(temp(i)); subplot(2,1,2); xyloObj = VideoReader('tempreading.mp4'); movie(mov,1,xyloObj.FrameRate); % I have also tried this nFrames = xyloObj.NumberOfFrames and imshow(video(n,:,:)); pause(0.01); currFrame = getframe(gcf); writeVideo(vidObj,currFrame); end
% Close the file.
close(vidObj);

Answers (0)

Community Treasure Hunt

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

Start Hunting!