필터 지우기
필터 지우기

Generating gifs that replay and controlling FPS in MATLAB

조회 수: 84 (최근 30일)
William Beswick
William Beswick 2022년 10월 26일
답변: DGM 2022년 11월 4일
I'm generating lots of figures representing a system and it would be useful to be if they were displayed in a GIF (so I don't have to keep clicking between them, they just skip automatically).
I'v been able to create a GIF using the exportgraphics command, the issues are:
1) it doesn't replay. After it has finished showing each image, it stops on the last image and thats it. I've tried saving and reloading, but the GIF stays stuck on the last image. I need to be able to save the file as a GIF to use with other software.
2) the FPS is really low. Ideally I'd like it to be about 50 frames over 2 seconds.
I'm using MATLAB online, I don't know if that helps

답변 (2개)

Eshan Patel
Eshan Patel 2022년 11월 4일
Hey William,
I see that you are using "exportgraphics" to create a GIF, and you require a better way to do it. You can address all the drawbacks you are currently facing by using the "imwrite" function, which will allow you to loop the GIF and add a custom delay to each frame.
Please have a look at the "Write Animated GIF" example in the documentation for "imwrite".

DGM
DGM 2022년 11월 4일
I don't have exportgraphics(), so I can't experiment with it, and I'm not sure how you're using it.
Off the top of my head, I don't recall how the loopcount is specified in the file header for GIF. My suspicion is simply that the way the file is being incrementally constructed is creating a problem.
That said, I use these tools for creating animated GIFs from 4D image arrays. You might have to do some extra intermediate work to get the images in that form, but that's what I have at hand. That'll handle per-frame delay specification, and it's infinite-looping by default.
There are other GIF tools on the FEX, but those are the ones I'm familiar with (because I wrote them).

카테고리

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

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by