0

波の伝播アニメーションを生成するために、contourf を使用しています。for ループの反復ごとにマトリックス内の 1 つの範囲だけに色を付けています。次に、生成する画像を gif としてアニメーション化しています。ウェーブ アニメーションの背景として機能するイメージを追加すると、アニメーションはアニメーションの進行に合わせてすべての色付き範囲を保持します。

ここにコードの一部があります

filename = 'heart18a.gif'; 
img = imread('heart_18.jpg');
 min_x = 0;
max_x = 661;
min_y = 0;
max_y = 749;
%plot the background and Z points
hold on
for n = min(z):1:max(z),
 imagesc([min_x max_x], [min_y max_y],img);
 plot(x,y,'.');
end
hold off
 i = 1;



  %loop and isomap generation
for n =1:1:14,    

hold on   
      contourf(XI,YI,ZI,[n n+1],'linecolor','black')

      colormap (jet)
      caxis ([-10 50])
      alpha(0.5);
%set the y-axis back to normal.
%set(gca,'ydir','normal');
hold off

      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
      i = i + 1;

end

ありがとう

4

0 に答える 0