1. Not finding help here? Sign up for a free 30min 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!

Need a little matlab help to graph a function

  1. Oct 23, 2008 #1
    1. The problem statement, all variables and given/known data
    Compare the triangular wave form in fig 6.5 with the graph of V(t)=1+(8/(n*pi))cos(2000*PI*t). Sum V(t) for odd integers of n from 1-19(1,3,5,7,9,..) and graph using a computer for 0<t<2. compare with the graph shown in the text.

    2. Relevant equations
    shown in problem. For the sum I just added the equation in my ti89 a bunch of times since i could not get matlab to work. here is the equation i got.


    I'm not at all sure this is right and kinda don't think it is but i can figure out how to get matlab to sum it up for me

    3. The attempt at a solution


    I this doesn't work right, and the one way i sort of got it to work it was just a straight line, which makes me think the equations is messed up. I'm quite frustrated with matlab right now as I have been having issues with it all week and really want to punch this 30inch screen at my schools computer lab.
    thanks for any help.
  2. jcsd
  3. Oct 25, 2008 #2
    It shouldn't be the sum of just one cosine term. Are you sure you wrote down the question right? Adding the same cosine term with a different amplitude 10 times doesn't make much sense to me. Periodic waveforms are composed of many sinusoids of different frequency and amplitude.

    As for your code, you're aliasing the summation. If you're only incrementing x by 1/1000 and the period of x is 1/1000 you're getting the same point over and over because it's periodic by exactly the amount you increment! Try using x=0:0.000001:0.002

    P.S. MATLAB is definitely super frustrating. I've learned to embrace it over the years though. It's a very powerful tool. Some simulations I do on there take days to execute.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Need a little matlab help to graph a function
  1. MATLAB Help needed! (Replies: 1)

  2. Matlab help needed (Replies: 3)

  3. Matlab Need Help (Replies: 1)