Need a little matlab help to graph a function

Click For Summary
SUMMARY

The discussion focuses on graphing a triangular waveform using MATLAB, specifically comparing it to the function V(t)=1+(8/(n*pi))cos(2000*PI*t) for odd integers of n from 1 to 19. The user initially attempted to sum the function using a TI-89 calculator but faced difficulties implementing it in MATLAB. Key issues identified include incorrect summation of the cosine terms and aliasing in the x variable increment, which resulted in a straight line graph instead of the expected waveform.

PREREQUISITES
  • Understanding of MATLAB syntax and functions
  • Familiarity with periodic waveforms and Fourier series
  • Knowledge of cosine functions and their properties
  • Basic graphing techniques in MATLAB
NEXT STEPS
  • Learn how to implement summation of series in MATLAB using loops or vectorization
  • Explore MATLAB's plotting functions for better visualization of periodic functions
  • Study the concept of aliasing in signal processing and its effects on graphing
  • Investigate the Fourier series representation of periodic waveforms
USEFUL FOR

Students and educators in engineering or physics, MATLAB users seeking to graph complex functions, and anyone interested in understanding periodic waveforms and their representations in computational tools.

HappMatt
Messages
89
Reaction score
0

Homework Statement


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.

Homework 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.

V(t)=(248303008*cos(200*pi*t))/(1459535*pi^2)+10

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


The Attempt at a Solution



x=0:0.001:2;
y=1+(8/(pi^2))cos(2000*pi*x.);
plot(x,y);

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.
 
Physics news on Phys.org
V(t)=(248303008*cos(200*pi*t))/(1459535*pi^2)+10

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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
6K
Replies
5
Views
3K
  • · Replies 21 ·
Replies
21
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 3 ·
Replies
3
Views
2K