I think i'm implementing the code wrong. I thoughts that the original and zero padded signal would be concatenated around the same point, with the same peaks. Is my understanding of this wrong or is my code the issue?
clc;clear;
N=257; %number of points in the signal
f=330.5; %frequency of signal
fs=1024; %sampling frequency
Ts=1/fs; %sampling period
ts=0:Ts:(N-1)/fs; %duration of signal
x=sin(f*ts);%generation of sampled signal
X=fftshift(fft(x)); %shifted FFT of signal
figure(5)
stem(abs(X))
M=2048; %number of points desired in the new signal that will be zero padded
zerovec=zeros(1,(M-N)); %creating enough 0's to add to the end of the original signal to achieve the desired length
x1=[x zerovec]; %concatenating original signal and 0's to get zero padded signal
X1=fftshift(fft(x1)); %fft of zero padded signal
figure()
stem(abs(X)) %discrete plot of original signal
hold on
stem(abs(X1)) %discrete plot of zero padded signal