How can I get gif images from the 300 by 300 raw pixels .txt files?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi I am trying to make a gif files from the amount of 500 text files. text files are saved like matrices such as
1.023000000000000000e+03 9.000000000000000000e+00 1.300000000000000000e+01
9.420000000000000000e+02 9.270000000000000000e+02 8.600000000000000000e+01
7.620000000000000000e+02 7.680000000000000000e+02 7.590000000000000000e+02
and I want to make only one gif files included 500 txt files.
Also, I want to make scale bar and automatic range (find minimum and maximum value and set that the minimum and maximum during the play.
Please start at opening the text files!
댓글 수: 0
답변 (1개)
KSSV
2018년 1월 23일
files = dir('*.txt') ; % get all text files in the folder
N = length(files) ; % total number of files
% gif starts
h = figure;
axis tight manual % this ensures that getframe() returns a consistent size
filename = 'test.gif';
for i = 1:N % loop for each file
% import the file
data = importdata(files(i).name) ;
surf(data) ;
colorbar
drawnow
% Capture the plot as an image
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Write to the GIF File
if n == 1
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end
댓글 수: 4
KSSV
2018년 1월 24일
files = dir('*.txt') ;
The above liens reads all test files in the present folder......you need to read about that.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!