Solving and Modeling a vibrating rectangular membrane.

21 views (last 30 days)
I am looking to solve a PDE problem involving a vibrating rectangular membrane given an initial displacement as well as some other necessary parameters. I believe I've constructed code which correctly solves the equation and stores the results, however I cannot seem to produce a movie/animation to view the solution. For example, the axes do not hold, so the plot is not smooth, where it should be moving fluidly frame by frame.
Anyways, my current code is attached, any suggestions are helpful.
  2 Comments
Diego Estevez
Diego Estevez on 18 Feb 2019
near line 12, you write size(x) but never specified what x is in any previous line. Can you tell us what it is?
Image Analyst
Image Analyst on 18 Feb 2019
Probably not - he hasn't been here in over 4 years.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 17 Jul 2014
Look at this snippet from my attached demo. If you still can't figure out how to fix it after adapting this, then let me know.
% Read the frames back in from disk, and convert them to a movie.
% Preallocate recalledMovie, which will be an array of structures.
% First get a cell array with all the frames.
allTheFrames = cell(numberOfFrames,1);
allTheFrames(:) = {zeros(vidHeight, vidWidth, 3, 'uint8')};
% Next get a cell array with all the colormaps.
allTheColorMaps = cell(numberOfFrames,1);
allTheColorMaps(:) = {zeros(256, 3)};
% Now combine these to make the array of structures.
recalledMovie = struct('cdata', allTheFrames, 'colormap', allTheColorMaps)
for frame = 1 : numberOfFrames
% Construct an output image file name.
outputBaseFileName = sprintf('Frame %4.4d.png', frame);
outputFullFileName = fullfile(outputFolder, outputBaseFileName);
% Read the image in from disk.
thisFrame = imread(outputFullFileName);
% Convert the image into a "movie frame" structure.
recalledMovie(frame) = im2frame(thisFrame);
% Write this frame out to a new video file.
writeVideo(writerObj, thisFrame);
end
close(writerObj);
% Get rid of old image and plot.
delete(hImage);
delete(hPlot);
% Create new axes for our movie.
subplot(1, 3, 2);
axis off; % Turn off axes numbers.
title('Movie recalled from disk', 'FontSize', fontSize);
% Play the movie in the axes.
movie(recalledMovie);
% Note: if you want to display graphics or text in the overlay
% as the movie plays back then you need to do it like I did at first
% (at the top of this file where you extract and imshow a frame at a time.)
msgbox('Done with this demo!');

Categories

Find more on Animation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!