let us consider following sinusoidal model
function [ x ] = generate1(fs,A3)
f1 = 25;
f2 = 27;
Ts = 1./fs;
t = (0:Ts:2.93)';
wn = rand(length(t),1); %zero mean variance 1
x = 20.*sin(2.*pi.*f1.*t) + 30.*cos(2.*pi.*f2.*t) + A3.*wn;
%[pks,locs] = findpeaks(x);
%plot(x)
end
generation of this signal can be easily done by following command
>> y=sinusoidal(100,5);
power spectrum plot of this sinusoidal signal using periodogram will be
> y=sinusoidal(100,5);
>> [pxx,f]=periodogram(y,[],[],100);
>> plot(f,pxx)
>>

i would like to calculate signal/noise ratio for given noisy signal but problem is that there is different type of signal/noisy calculation,for example like this
snr_before = mean( signal .^ 2 ) / mean( noise .^ 2 );
snr_before_db = 10 * log10( snr_before ) % in dB
or given snr function in matlab,there is explanation of this
http://www.mathworks.com/help/signal/ref/snr.html
please help me to choose correct one,i mean which one i should use and in which case ?thanks in advance