%% ========================================================= % Data % ========================================================= X = single(raw_DPW.Data); X = X(:,:,1:end); % first DPW useless (zeroed) %% ========================================================= % Parameters % ========================================================= Fs = 512e6; % Sampling rate (Hz) N = 512; % Frame size % Your data variable (rename if needed) % Expected size: [512 x 4 x 8] % X(frameSamples, frameIndex, timeIndex) % Example: X = your_workspace_variable; [nSamples, nFrames, nTime] = size(X); %% ========================================================= % FFT Computation % ========================================================= FFT_all = zeros(N, nFrames*nTime); idx = 1; for t = 1:nTime for f = 1:nFrames x = X(:, f, t); % Optional window (uncomment if needed) % w = hann(N); % x = x .* w; Xf = fftshift(fft(x)); FFT_all(:, idx) = abs(Xf); idx = idx + 1; end end %% ========================================================= % Axes % ========================================================= f_axis = (-N/2 : N/2-1) * (Fs/N) / 1e6; % MHz t_axis = 1:(nFrames*nTime); % frame index %% ========================================================= % Spectrogram-like view (BEST) % ========================================================= figure; surf(t_axis, f_axis, 20*log10(FFT_all + 1e-12), 'EdgeColor', 'none'); view(2); axis tight; xlabel('Frame index'); ylabel('Frequency (MHz)'); title('FFT over time (per frame)'); colorbar; %% ========================================================= % 3D Visualization (optional) % ========================================================= figure; surf(t_axis, f_axis, FFT_all, 'EdgeColor', 'none'); xlabel('Frame index'); ylabel('Frequency (MHz)'); zlabel('Magnitude'); title('3D FFT evolution'); %% ========================================================= % Single frame debug (optional) % ========================================================= figure; x_dbg = X(:,end,end); Xf_dbg = fftshift(fft(x_dbg)); plot(f_axis, 20*log10(abs(Xf_dbg)+1e-12)); grid on; xlabel('Frequency (MHz)'); ylabel('Magnitude (dB)'); title('Single Frame FFT');