function classifysignalwithadditionalfeatures() % Parameters fs = 1000; % Sampling…
- User
function classify_signal_with_additional_features() % Parameters fs = 1000; % Sampling frequency fc = 100; % Carrier frequency dataLength = fs; % Length of data (1 second of data) numTests = 1000; % Number of signals to test per modulation type
modTypes = {'ASK', 'FSK', 'PSK', 'AM', 'FM', 'MSK'}; correctCount = 0; totalCount = 0; actualModTypes = {}; predictedModTypes = {}; % Store feature values for logging featureValues = struct(); for modType = modTypes featureValues.(modType{1}) = []; end % Loop over each modulation type for tests for i = 1:length(modTypes) modType = modTypes{i}; for j = 1:numTests data = randi([0 1], 1, dataLength); signal = generateModulatedSignal(data, fs, fc, modType); [sigma_ap, sigma_af, sigma_dp] = extract_features(signal, fs); renyi_entropy = compute_renyi_entropy_stft(signal, fs); phase_variance = compute_phase_variance(signal, fs); spectral_flatness = compute_spectral_flatness(signal); frequency_stability = compute_frequency_stability(signal, fs); % Add the nonlinear phase peak factor nonlinear_phase_peak_factor = compute_differential_nonlinear_phase_peak_factor(signal, fs, fc); detectedModType = classify_with_additional_features(sigma_ap, sigma_af, sigma_dp, renyi_entropy, phase_variance, spectral_flatness, frequency_stability, nonlinear_phase_peak_factor); % Append to classification results actualModTypes{end+1} = modType; predictedModTypes{end+1} = detectedModType; % Store the feature values featureValues.(modType){end+1} = [sigma_ap, sigma_af, sigma_dp, renyi_entropy, phase_variance, spectral_flatness, frequency_stability, nonlinear_phase_peak_factor]; if strcmp(detectedModType, modType) correctCount = correctCount + 1; end totalCount = totalCount + 1; end end accuracy = (correctCount / totalCount) * 100; fprintf('Total Accuracy: %.2f%%\n', accuracy); % Print feature values for all modulation types for i = 1:length(modTypes) modType = modTypes{i}; fprintf('\n%s Feature Averages (over %d tests):\n', modType, numTests); featuresMatrix = cell2mat(featureValues.(modType)'); avgFeatures = mean(featuresMatrix, 1); fprintf('Sigma_ap (Amplitude STD): %.4f\n', avgFeatures(1)); fprintf('Sigma_af (Frequency STD): %.4f\n', avgFeatures(2)); fprintf('Sigma_dp (Phase STD): %.4f\n', avgFeatures(3)); fprintf('Renyi Entropy: %.4f\n', avgFeatures(4)); fprintf('Phase Variance: %.4f\n', avgFeatures(5)); fprintf('Spectral Flatness: %.4f\n', avgFeatures(6)); fprintf('Frequency Stability: %.4f\n', avgFeatures(7)); fprintf('Nonlinear Phase Peak Factor: %.4f\n', avgFeatures(8)); end % Plot the confusion matrix figure; confusionchart(actualModTypes, predictedModTypes, 'RowSummary', 'row-normalized', 'ColumnSummary', 'column-normalized'); title('Confusion Matrix for Modulation Classification');end
function modType = classify_with_additional_features(sigma_ap, sigma_af, sigma_dp, renyi_entropy, phase_variance, spectral_flatness, frequency_stability, nonlinear_phase_peak_factor) % Updated classification rules based on expanded features
- Assistant
- User
use other parameters to differentiate MSk and PSk as their features are overlapping
- Assistant
- User
give full new code
- Assistant
- User
PSK Feature Averages (over 1000 tests): Sigma_ap (Amplitude STD): 0.3449 Sigma_af (Frequency STD): 209.7623 Sigma_dp (Phase STD): 342.1296 Renyi Entropy: 2.3044 Phase Variance: 1.7389 Spectral Flatness: 0.5600 Frequency Stability: 209.7623 Nonlinear Phase Peak Factor: 0.0000 Phase Smoothness: -3.2046
MSK Feature Averages (over 1000 tests): Sigma_ap (Amplitude STD): 0.3449 Sigma_af (Frequency STD): 209.6033 Sigma_dp (Phase STD): 341.5122 Renyi Entropy: 2.3044 Phase Variance: 1.7364 Spectral Flatness: 0.5593 Frequency Stability: 209.6033 Nonlinear Phase Peak Factor: 0.0000 Phase Smoothness: -3.2000
Use any other feature it is not working
- Assistant
- User
give full code also print all average paramters clearly
- Assistant
- User
PSK Feature Averages (over 1000 tests): Sigma_ap (Amplitude STD): 0.3445 Sigma_af (Frequency STD): 209.4002 Sigma_dp (Phase STD): 343.3010 Renyi Entropy: 2.3044 Phase Variance: 1.7328 Spectral Flatness: 0.5606 Frequency Stability: 209.4002 Nonlinear Phase Peak Factor: 0.0000 Phase Smoothness: -3.1864 Zero Crossings: 500.5380
MSK Feature Averages (over 1000 tests): Sigma_ap (Amplitude STD): 0.3445 Sigma_af (Frequency STD): 209.6813 Sigma_dp (Phase STD): 343.4040 Renyi Entropy: 2.3044 Phase Variance: 1.7375 Spectral Flatness: 0.5606 Frequency Stability: 209.6813 Nonlinear Phase Peak Factor: 0.0000 Phase Smoothness: -3.1979 Zero Crossings: 499.9390
Update the parameters
- Assistant
- User
still very less accuracy use new features or filters
- Assistant
- User
give full code
- Assistant
- User
give me full code with generating functions and all that ... also do not use cwt
- Assistant
- User
Unrecognized function or variable 'cyclicspec'.
Error in classify_signal_with_additional_features>compute_cyclostationary_features (line 88) cycspectrum = abs(cyclicspec(signal, cyclic_freqs, fs));
Error in classify_signal_with_additional_features (line 38)
- Assistant
- User
MSK Feature Averages (over 1000 tests): DWT Feature 1: 0.4990 DWT Feature 2: 0.5010 Cyclostationary Feature 1: 101.7985 Cyclostationary Feature 2: 57.6328
PSK Feature Averages (over 1000 tests): DWT Feature 1: 0.5001 DWT Feature 2: 0.4998 Cyclostationary Feature 1: 119.2888 Cyclostationary Feature 2: 65.0143
Udate this code below based on the above paramerters keep rest same only change PSK and PSK
- Assistant
Given the feature averages you've provided for MSK and PSK, we can update the classification logic specifically for these two modulation types based on their extracted features. The goal is to establish thresholds that will effectively discriminate between MSK and PSK using the values you've provided.
- User
give full code
- Assistant
- User
also classify other features given as per my previous code
- Assistant
- User
PSK Feature Averages (over 1000 tests): Sigma_ap (Amplitude STD): 0.3440 Sigma_af (Frequency STD): 209.7346 Sigma_dp (Phase STD): 342.1741 Renyi Entropy: 2.3044 Phase Variance: 1.7384 Spectral Flatness: 0.5596 Frequency Stability: 209.7346 DWT Feature 1: 0.4998 DWT Feature 2: 0.5003 Cyclostationary Feature 1: 93.2882 Cyclostationary Feature 2: 49.8783
MSK Feature Averages (over 1000 tests): Sigma_ap (Amplitude STD): 0.3446 Sigma_af (Frequency STD): 209.5951 Sigma_dp (Phase STD): 343.0993 Renyi Entropy: 2.3044 Phase Variance: 1.7362 Spectral Flatness: 0.5594 Frequency Stability: 209.5951 DWT Feature 1: 0.5001 DWT Feature 2: 0.5000 Cyclostationary Feature 1: 117.5571 Cyclostationary Feature 2: 59.6573
What should be the thresholds
- Assistant
- User
most of the MSK and PSK are still going into unknown fix it ...
- Assistant
- User
elseif (sigma_ap >= 0.335 && sigma_ap <= 0.355 && sigma_af >= 204 && sigma_af <= 228 ... && sigma_dp >= 319 && sigma_dp <= 364 && renyi_entropy >= 2.29 && renyi_entropy <= 2.31) Should we keep this condition or not?
- Assistant
- User
whenever wave is a psk or msk i want the cyclostationary feature 1 and 2 to be printed
- Assistant
- User
give me new code to simulate the process of generating 1000 PSk and MSK waves and printing cyclostationery features for them
- Assistant
- User
why are the values varying so wildly so each testcase
- Assistant
- User
- Assistant
- User
use support vector machine to differentiate this
- Assistant
- User
SVM Classification Accuracy: 49.25% Why this
- Assistant
- User
SVM Classification Accuracy: 53.00% Confusion Matrix: 99 101 87 113
Still this improve it
- Assistant
- User
SVM Classification Accuracy: 51.25% Confusion Matrix: 112 88 107 93 improve using some other method
- Assistant
- User
simulate_psk_msk_features Random Forest Classification Accuracy: 49.75% Confusion Matrix: 97 103 98 102
Use something else
- Assistant