![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1106600/image.gif)
Read First n line then plot and read next lines and plot and collectively make movie of all graphs.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Yashvardhan Bhati
am 24 Aug. 2022
Kommentiert: Yashvardhan Bhati
am 27 Aug. 2022
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.
0 Kommentare
Akzeptierte Antwort
KSSV
am 24 Aug. 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1106600/image.gif)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Animation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!