2

I am new to using MATLAB and used a plot to generate the graph for a simple sinusoid. The plot is that of a $50$Hz signal, $y=20\sin(100\pi t)$; it was plotted from $-1$ to $1$ sec the plot which I got was this enter image description here

I thought that the problem might be with my $x$ axis range, (although still the graph should not be as uneven. This looks more like a mixture of multiple sinusoids than a single, at least the peaks should be at the same height) and decided to lower my range ($-0.1$sec to $0.1$sec) by reducing the axes stretch on the graph, the figure which I got was this enter image description here

Now, I got really confused and further lowered the axes limits to ($-0.02$sec to $0.02$sec). This I figured should give me some sense of what is happening, the result I get is enter image description here

Could any one help me with what is going on, I am absolutely clueless...

  • 3
    Is $t$ a array you have made? One problem might be that your function on $[-1,1]$ has $100$ full periods so you need to have enough points in the $t$ array (atleast $1000$) to propertly map out the function. – Winther Nov 09 '14 at 01:20
  • yes, I have made t as an array. I used t=[-1:0.01:1]; – ubuntu_noob Nov 09 '14 at 01:22
  • 2
    There is your problem, you are undersampling your function. Try $t=[-1:0.0001:1]$ – Winther Nov 09 '14 at 01:23
  • Okay. You are absolutely correct. Thanks a lot man, on the lighter side, I am starting to learn MATLAB so that I can learn DSP signal resolution and got bowled in my first attempt by resolution issues in the time domain.Tell me something, do I absolutely HAVE to deal with arrays and matrices in MATLAB or can I use pure analog independent variables? Is there a way around this resolution hurdle at the primary step?? – ubuntu_noob Nov 09 '14 at 01:30
  • 1
    You can try ezplot to plot a symbolic function. E.g. to plot $y = x^2$ try: syms x y (newline) ezplot(x^2 == y) – Winther Nov 09 '14 at 01:33
  • Yes dude, it works absolutely fine and it also takes care of the resolution issues. Thanks a lot man, people like you make learning fun :) – ubuntu_noob Nov 09 '14 at 01:51

0 Answers0