Problem Creating Animated Gif File

조회 수: 8 (최근 30일)
Shay Saliba
Shay Saliba 2011년 7월 22일
I am having trouble getting my code to create an animated gif of the following plot. It only displays the first frame slightly transparent. Any help is greatly appreciated. My code is shown below.
P = linspace(150,800,31);
F = linspace(50,600,41);
ICP = 1000:-10:100;
figure(1)
axis([150 800 50 600 0 20]);
ylabel('Flow (SCCM)');
xlabel('Pressure (mTorr)');
zlabel('Non-Uniformity');
set(gca,'nextplot','replacechildren');
for k = 1:length(ICP)
for j = 1:length(P)
for i = 1:length(F)
if 1.156*P(j)-97.15 > F(i)
UN(i,j) = Descum(P(j),F(i),ICP(k));
else
UN(i,j) = NaN;
end
end
end
surf(P,F,UN);
title(['ICP = ' num2str(ICP(k))]);
Frame(k) = getframe(1);
im = frame2im(Frame(k));
[imind,cm] = rgb2ind(im,256);
if k == 1;
imwrite(imind,cm,'DescumGif','gif','Loopcount',inf);
else
imwrite(imind,cm,'DescumGif','gif','WriteMode','append');
end
end

답변 (1개)

Jan
Jan 2011년 7월 23일
I've used RAND instead of the unknown function Descum and it ran fine. Perhaps your single picture use completely different colormaps? Then use the cm of the first frame for the others inside RGB2IND:
if k == 1
[imind, cm] = rgb2ind(im,256);
imwrite(imind, cm, 'DescumGif', 'gif', 'Loopcount', inf);
else
imind = rgb2ind(im, cm);
imwrite(imind, cm, 'DescumGif', 'gif', 'WriteMode', 'append');
end
  댓글 수: 2
Shay Saliba
Shay Saliba 2011년 7월 25일
Substituting this code didn't change anything. Descum is just a simple equation:
function NU = Descum(P,F,ICP)
NU = 17.49887-0.046082.*P+0.017485.*F+3.54769*ICP.*10.^-3-4.41811.*10.^-5 ...
.*P.*F-1.0845.*10.^-5.*P.*ICP+1.51022.*10.^-5.*F.*ICP+4.57205.*10.^-5.*P.^2+ ...
1.63512.*10.^-5.*F.^2+1.77673.*10.^-6.*ICP.^2;
end
Thanks for the help
Jan
Jan 2011년 7월 25일
@Shay: Your code runs fine on my computer. Please explain what this means exactly: "It only displays the first frame slightly transparent". Does Matlab have problems with the display? Does your function run through all iterations? Can you post the created picture?

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by