Generating gifs that replay and controlling FPS in MATLAB

121 ビュー (過去 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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by