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!

Homework Help: MatLab Animation Problem

  1. May 5, 2013 #1


    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
    %shading interp

    while theta < 4*pi;
    z = sin(x-theta) * cos(y-theta);
    theta = theta+(pi/50);

    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.

    Last edited: May 5, 2013
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

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