Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

KSSV
KSSV le 24 Août 2022
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
  1 commentaire
Yashvardhan Bhati
Yashvardhan Bhati le 27 Août 2022
Thank you for the solution, works perfectly. If possible can you tell how to save it as avi file and not gif format.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by