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