From FFT to PSD using Pwelch Matlab I am trying to understand the difference between FFT magnitude and PSD (Power spectral density) with pwelch function of Matlab. In my example, Val1 and Val2 will output the same thing?

% N = 94144

% fs = 44100

segmentLength = N; % window size

[pxx,f] = pwelch(signal,segmentLength,[],segmentLength,fs);

%pwelch(data,segmentLength,overlappedSamples,segmentLength,fs);

Y = fft(signal);

Y_mag = abs(Y);

Val1 = 20*log10(Y_mag);

Val2 = 10*log10(pxx);


PS: I have already seen the other posts and I understand very well the difference between PSD and FFT but here I am interested in the diffeeence in code. Thanks
Pwelch does not just use one fft, it applies several ffts , windowing, scaling and averaging.If you do all that you may get equality.  Here is example equality of fft &amp; pwelch:

N = 94144;
x = randn(1,N);
pwr1 = pwelch(x,ones(1,N),0,N,1,'twosided');
y = fft(x);
pwr2 = abs(y).^2;
plot(pwr1);
hold
plot(pwr2*max(pwr1)/max(pwr2),'r--');