필터 지우기
필터 지우기

Read First n line then plot and read next lines and plot and collectively make movie of all graphs.

조회 수: 1 (최근 30일)
I am trying to read data from file. Now i would like to read first suppose n=337 lines and plot the data for the same, now repeat same for the next 337 lines and untill the end. Now i would like to make movie of the graphs\plots with same x and y axis generated into single mvi file.
T=readtable('Plug.txt','ReadVariableNames',true);
F = scatteredInterpolant(T.XC, T.YC, T.VY);
[xmin, xmax] = bounds(T.XC);
[ymin, ymax] = bounds(T.YC);
x0 = linspace(xmin, xmax, 409);
y0 = linspace(ymin, ymax, 337);
[xq, yq] = meshgrid(x0, y0);
zq = F(xq, yq);
this is how i am planning to go ahead with reading the file but how to loop and save all the plots into animation. One of the static images can be found below but what i want is that movie whcih procceds with first showing y=0 data and then y=1 y=2.... till y=87.

채택된 답변

KSSV
KSSV 2022년 8월 24일
T=readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1106475/Plug.txt\Plug.txt','ReadVariableNames',true);
x = T.XC ;
y = T.YC ;
vy = T.VY ;
xv = unique(x) ;
yv = unique(y) ;
nx = length(xv) ;
ny = length(yv) ;
figure(1)
filename = 'test.gif';
for i = 1:ny
plot(x(y==y(i)),vy(y==y(i)))
ylim([-8 1])
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if i == 1
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by