Skip to main content

Posts

Showing posts with the label MATLAB

MATLAB: Sinusoids with Gaussian, Uniform, Laplace, Binary, and Pink Noise

  MATAB Code %% ========================================================== %  WSS / Noise Demonstration Simulator %  Sinusoid + Multiple Noise Types %  Distribution + Autocorrelation + PSD %  LTI System Demonstration %% ========================================================== clear; close all; clc; %% Parameters Fs = 1000;              % Sampling Frequency N  = 5000;              % Number of Samples t  = (0:N-1)/Fs; A  = 1;                 % Sinusoid Amplitude f0 = 20;                % Sinusoid Frequency signal = A*sin(2*pi*f0*t); noiseVariance = 0.25; noiseStd = sqrt(noiseVariance); %% ========================================================== % Generate Noise Types %% ========================================================== % Gaussian Noise gaussianNoise = noiseStd*randn(1,N); % Uniform No...

Medical Image Denoising (MATLAB): Scale 32x32 Filter Coefficients to 128x128

MATLAB Implementation MATLAB Script Copy Code %% MEDICAL IMAGING SYSTEM IDENTIFICATION & RECONSTRUCTION % Project: Pilot-Based CIR Estimation for Medical Image Denoising % Methodology: 32x32 Phantom Calibration -> 128x128 Diagnostic Restoration clear; clc; close all; %% 1. SYSTEM PARAMETERS (Industrial Standards) target_snr_db = 30; % Signal-to-Noise Ratio pilot_dim = 32; % Calibration Grid data_dim = 128; % Diagnostic Grid % Simulated Hardware Blur (Point Spread Function) true_psf = fspecial('gaussian', [5 5], 1.2); %% 2. CALIBRATION PHASE (32x32 Pilot) % Use the Shepp-Logan Phantom (Industry standard for medical imaging) pilot_clean = phantom(pilot_dim); % Distort the Pilot (Convolution + System Noise) pilot_blurred = imfilter(pilot_clean, true_psf, 'circular'); % Add Signal-Dependent Noise (Simulating Quantum Mottle) noise_var = mean(pilot_blurred(:)) / (10^(ta...

(AM) Free MATLAB alternative for signal analysis

Signal Analyzer Upload CSV, .wav, or .mp4 Use Test Signal CSV Sample Rate (Hz): Generate CSV No Operation FFT (Spectrum) Amplitude Modulation (AM) Double Sideband Supressed Carrier (DSBSC) Pulse Amplitude Modulation (PAM) Flat Top PAM Filters - LPF, HPF, BPF, Notch Principal Component Analysis (PCA) Cross Spectrum ...

Advanced Signal Filtering in MATLAB: Notch, Low-Pass & Resonator for Clean Spectra

  MATLAB Code %% Advanced Filter Visualization: The "Signal Cleaner" clc; clear; close all ; % --- 1. SETUP PARAMETERS --- fs = 1000; % Sampling frequency (1kHz) T = 1.5; % Duration in seconds t = (0:1/fs:T-1/fs)'; % Time vector % --- 2. CREATE A "MESSY" INPUT SIGNAL --- % Desired Signal: 20 Hz (Clean sine wave) s1 = 1.0 * sin(2*pi*20*t); % Interference 1: 50 Hz (Strong Power-line Hum) - TARGET FOR NOTCH n1 = 0.8 * sin(2*pi*50*t); % Interference 2: 150 Hz (High-frequency Noise) - TARGET FOR LOW-PASS n2 = 0.6 * sin(2*pi*150*t); % The combined "Dirty" signal x = s1 + n1 + n2; % --- 3. DESIGN ANALOG FILTERS (using coefficients) --- % A. Notch Filter @ 50 Hz (Deep cut at exactly 50Hz) f0 = 50; w0 = 2*pi*f0; Q = 10; % Quality factor (higher = narrower notch) b_notch = [1 0 w0^2]; a_notch = [1 w0/Q w0^2]; % B. Low-Pass Filter @ 80 Hz (Blocks 150Hz) fc = 80; wc = 2*pi*fc; [b_lp, a_lp] = butter(2, wc, 's' ); % 2nd order Bu...

MATLAB Code for PCA

  MATLAB Code %% Multipath PCA Simulator GUI function multipath_pca_gui close all ; clear; clc; % Parameters N = 200; % Number of samples t = linspace(0,1,N); % Time vector % Create Figure fig = figure( 'Name' , 'Multipath PCA Simulator' , 'Position' ,[100 50 1200 700]); % Axes ax1 = subplot(3,2,1); title(ax1, 'Transmitted Signal' ); xlabel(ax1, 'Sample Index' ); ylabel(ax1, 'Amplitude' ); ax2 = subplot(3,2,2); title(ax2, 'Received Multipath Signals' ); xlabel(ax2, 'Sample Index' ); ylabel(ax2, 'Amplitude' ); ax3 = subplot(3,2,3); title(ax3, 'Eigenvalue Spectrum' ); xlabel(ax3, 'Principal Component' ); ylabel(ax3, 'Variance' ); ax4 = subplot(3,2,4); title(ax4, 'Top Principal Components (PCA)' ); xlabel(ax4, 'Sample Index' ); ylabel(ax4, 'PC Value' ); ax5 = subplot(3,2,[5,6]); title(ax5, 'Reconst...

Cross-Spectrum Explained (with MATLAB)

Cross-Spectrum: Concept and Mathematics The cross-spectrum measures the frequency-domain correlation between two signals, showing how the signals relate in magnitude and phase at each frequency. For two discrete-time signals x[n] and y[n] , the cross-spectral density is defined as: S xy (f) = X(f) · Y * (f) X(f) = FFT{x[n]} → Fourier transform of x[n] Y(f) = FFT{y[n]} → Fourier transform of y[n] Y*(f) → Complex conjugate of Y(f) |S xy (f)| → Magnitude shows correlation strength at each frequency ∠S xy (f) → Phase shows relative phase difference Cross-spectrum is widely used in: Beamforming Coherence analysis Direction-of-arrival estimation (DoA) Identifying frequency-dependent relationships between signals MATLAB Code Example This MATLAB example demonstrates the cross-spectrum between two sinusoidal signals with a phase difference: %% Cross-Spectrum Demonstration clc; clear; clo...

MATLAB 2D/3D Beamforming Simulation with Cross-Spectrum Analysis for Antenna Arrays

  MATLAB Code %% 2D Conceptual + Electronically Steered Beamforming clc; clear; close all ; %% PARAMETERS Fs = 1000; % Sampling frequency [Hz] T = 1/Fs; % Sampling period t = 0:T:1-T; % 1-second time vector f_sig = 50; % Signal frequency [Hz] %% SIMULATE ANTENNA SIGNALS p = sin(2*pi*f_sig*t); % Reference signal (antenna p) vx = 0.8*sin(2*pi*f_sig*t + pi/6); % vx antenna vy = 0.6*sin(2*pi*f_sig*t + pi/4); % vy antenna %% NORMALIZE SIGNALS pnor = p / max(abs(p)); vxnor = vx / max(abs(vx)); vynor = vy / max(abs(vy)); %% PASSIVE ROTATION (Conceptual Beamforming) I1 = real(fft(pnor) .* conj(fft(vxnor))); I2 = real(fft(pnor) .* conj(fft(vynor))); theta = 360 * atan(sum(I2)/sum(I1)) / (2*pi); % degrees vc = vxnor * cosd(theta) + vynor * sind(theta); resultant_passive = pnor + 2*vc; %% ELECTRONICALLY STEERED BEAM theta_steer = 60; % Desired steering angle in degrees lambda = 1; % Normalized wavelength d = 0.5*lambda; ...


Contact Us

Name

Email *

Message *