I have two approaches to do that when working in MATLAB.
The first is to generate a clean sine wave, and then apply a distorting function. For instance applying x*(1+kx^2) for small k to your sinewave vector x would give small amounts of even harmonics. Use v^3 for odd harmonics. k=0 gives the original signal vector, increase k for more distortion. I don't usually calibrate what k does, just fft and see what it's given me, and adjust k to taste.
The second is to inverse fourrier transform a vector containing your frequency specification. So you'd create a vector like [dc_val, 1, second_level, third level, ... ], and then apply ifft to turn it into a time vector. Note that MATLAB is one of the few languages still stuck in the BASIC and FORTRAN dark ages by using 1-based arrays. This means the dc term is index 1, sine term 2, 2nd harmonic 3 etc.
Note the frequency specification vector is complex, so you may get an unrealistic looking waveform if you use real coefficients for all your harmonics, and they all add up in phase Gibbs-style. If that's not acceptable, the kludge is to add a random phase to each frequency component before transformation.