Top 10 Reasons Why Your Matlab Program Isn't Working
TOP 10 REASONS WHY YOUR !@#$%^&
MATLAB PROGRAM ISN'T WORKING
IN ORDER OF LIKELIHOOD OF THIS BEING THE PROBLEM:
Your copy of Matlab doesn't include the right "toolboxes":
- "Undefined function or variable..." likely means this.
- EECS 216 labs require Matlab's "Signal Processing Toolbox"
and Matlab's Simulink. Matlab in CAEN labs have these.
- But Central Campus copies of Matlab likely don't have these.
The default number of points used in plot is too small.
- The Matlab default for the plot command is to use 100 points.
This is too small to pick up sharp peaks or dips properly.
- This happened to me so many times that I deliberately left
a couple in my lecture notes, to make the point in lecture.
You omitted the "." in X.*Y, so you're computing X*Y.
- Try T=linspace(0,1,1000);plot(sin(1./T)) without the . in ./
- This function has a lot of weird properties; mathematicians love it!
You think X is a column vector, when it's actually a row vector.
- EX: R=roots([1 -3 2]) produces a column vector R=[1 2]'
- zplane(R) will plot R directly, not the roots of the polynomial R.
- You can check this using size(R) to see what size you've got.
You used T=0:0.01:1 instead of T=linspace(0,1,100).
- Don't see the difference? Try it. The first generates 101 values of T.
- The second does NOT generate successive values of T separated by 0.01.
You made a typing mistake somewhere in your program.
- You mistyped x for X, or vice-versa (Matlab is case-sensitive).
- You simply mistyped a weird variable name, like dft_chop.
You forgot to save your modified .m file before rerunning Matlab.
- Or you saved it in the wrong directory (you'd be surprised how often).
- Or you forgot to use clear at the beginning to erase previous values.
Your program conditioning or loop structure is messed up somehow.
- Something is messing up your for-end;if-else-break-end;while-end.
- Or you may have forgotten that % begins a comment statement in Matlab.
You forgot the most basic rule of all of computer programming:
- A computer will always do exactly what you tell it to do.
- But that may not be what you had in mind!