Making a movie from the data files in matlab

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 5K views
vissu219
Messages
3
Reaction score
0
hi guys..i have a set of datafiles(more than 500)for each set i have to plot a graph and make a movie with them.. i want to knw how do i load all these files and plot them in a loop..the files are named as v1 v2 etc...and simeltaneously generate frames and make a movie.pls help ppl..
 
Physics news on Phys.org
simple example from a m - file have on "desk". The way usually do it is to inquire what files exist in a folder (using internal MATLAB commands for this) or derive the filenames using text-processing functions like strcat below, and then do the reading and storing in a for loop. Further processing then similarly, easiest to do it all in m - files.

Code:
%creating a cell array for data storage
all_data=cell(number_of_files,1);

for i=0:number_of_files-1
    %filename for current read
    filename_reading=strcat(input_path,specimen_id,'_',int2str(i) ,'.matlab_ascii');
    %reading all data to a cell array, +1 to get proper indices    
    all_data{i+1}=dlmread(filename_reading);
end

number_of_files, input_path, specimen_id are strings defined previously.