GRAPHICS FUNCTION CODE ERROR
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
title('Wave Function for a Particle in a 2D Box') % Title
drawnow
f = getframe(1);
im = frame2im(f);
[Q,map] = rgb2ind(im,256);
outfile = '2DParticle44.gif'; % FIle name to save the generated .gif file
Generates an error saying
Error using graphicsversion
Input was not a valid graphics object
Error in getframe (line 50)
usingMATLABClasses = ~graphicsversion(parentFig, 'handlegraphics');
Error in PROJ2 (line 40)
f = getframe(1);
I'm using MATLAB_R2013A.Please help debugging the code.
0 Commenti
Risposte (1)
Geoff Hayes
il 28 Gen 2016
Varshitha - in your call to getframe, you are passing 1. What does this refer to? According to the documentation for R2014a, F = getframe(h) gets a frame from the figure or axes identified by handle h. The error message is telling you that the 1 you are passing is not the handle of any figure.
f = getframe(gcf);
Else determine the function handle and use that instead. For example,
hFunc = figure;
% your other code to plot something on the figure
f = getframe(hFunc);
Try the above and see what happens!
2 Commenti
Geoff Hayes
il 29 Gen 2016
Varshitha - when I run your code, I observe the following error
Error using writegif (line 138)
3-D data not supported for GIF files. Data must be 2-D or 4-D.
Error in imwrite (line 472)
feval(fmt_s.write, data, map, filename, paramPairs{:});
Error in XXXXX (line 43)
imwrite(Q,map,outfile,'gif','LoopCount',Inf,'DelayTime',10);
Is that the error that you are seeing (which is different than the one that you originally posted)? I am running R2014a so that might explain a difference between your system and mine. (Though I get this same error when using an example from imwrite within the R2014a documentation…?)
As for the figure being "blank", have you stepped through the code to verify that the data that you are passing into surf makes sense?
Vedere anche
Categorie
Scopri di più su Animation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!