1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MatLab Animation Problem

  1. May 5, 2013 #1

    MacLaddy

    User Avatar
    Gold Member

    1. The problem statement, all variables and given/known data

    Create an animation of the following:

    Let x vary from -2pi to 2pi
    Let y = sin(x)
    Let z = sin(x-theta) * cos(y-theta)

    Let theta be the animation variable

    remember, you will need to mesh x and y to create a two-dimensional
    matrices: use the resulting arrays to find z


    2. Relevant equations

    3. The attempt at a solution

    This is what I've tried so far, and it is following closely with an example in my book.

    clear, clc, clf
    X = [-2*pi:pi/50:2*pi];
    theta = 0;
    Y = sin(X);
    [x,y] = meshgrid(X,Y);
    z = (sin(x-theta) * cos(y-theta));
    h = surf(z);
    axis tight
    set(gca,'nextplot','replacechildren');
    %shading interp
    %colormap(jet)

    while theta < 4*pi;
    z = sin(x-theta) * cos(y-theta);
    theta = theta+(pi/50);
    set(h,'ZData',z);
    drawnow
    end

    I've been wracking my brain for a while over this, and I'm failing to see what isn't varying correctly. Any help, or a nudge in the right direction, will be appreciated.

    Thanks,
    Mac
     
    Last edited: May 5, 2013
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: MatLab Animation Problem
  1. Matlab Problem (Replies: 0)

  2. Problem in matlab (Replies: 1)

Loading...