0

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

`clc; close all; clear all;
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);`
  • What do you mean a video file of the experiment? A video of you actually doing things that is recorded with a camera? Or can what you are talking about be taken care of by simply using subplot and displaying both items side-by-side before capturing the frame? – AnonSubmitter85 Jun 06 '14 at 00:44
  • it's a video of me doing the experiment itself. I have used the subplot function to display the graph but can't get it to show the video. – user3712173 Jun 06 '14 at 14:57
  • I have added the code in the description. – user3712173 Jun 06 '14 at 15:05
  • Try displaying the video one frame at a time and using `getframe()` to capture the figure. Once you have the frame array, you can use `movie2avi()` or some similar function to write the video back to file. – AnonSubmitter85 Jun 07 '14 at 00:24

0 Answers0