ysnr

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <title></title>
 </head>
 <body>
  <div id="box">
   the first paragraph...
   <p>
    the secound paragraph...
    <a href="http://www.example.com">thied</a>
   </p>
  </div>
 </body>
</html>
Line 756: 09-04 15:51:07.495407 656 671 I keystore2: system/security/keystore2/src/maintenance.rs:343 - apex modules += com.android.adbd version 360527520 Line 909: 09-04 15:51:07.885328 813 813 D aconfigd_mainline: aconfigd_rust::aconfigd: start initialize com.android.adbd flags Line 1059: 09-04 15:51:08.065497 817 817 D vold_prepare_subdirs: Setting up mode 771 uid 0 gid 1000 context u:object_r:apex_module_data_file:s0 on path: /data/misc_de/0/apexdata/com.android.adbd Line 23508: 09-04 15:51:18.085916 1754 1754 D CompatConfig: No directory /apex/com.android.adbd/etc/compatconfig, skipping Line 25057: 09-04 15:51:19.382368 1754 1754 W PackageManager: No package known for package restrictions com.google.android.adbd Line 25417: 09-04 15:51:19.503966 1754 1754 D PackageManager: Directories scanned as system partitions: [/system:0, /vendor:524288, /odm:4194304, /oem:262144, /product:1048576, /system_ext:2097152, /my_product/non_overlay:1048576, /my_stock/non_overlay:1048576, /mnt/opex/com.oplus.odmf@16000005:2097152, /mnt/opex/com.oplus.moduleservices@15000014:2097152, /mnt/opex/com.oplus.fancyIconLoader@1000000:2097152, /mnt/opex/com.oplus.NetworkAssistSys@16000021:2097152, /mnt/opex/com.oplus.CustCore@16000001:2097152, /my_company:1048576, /my_carrier:1048576, /my_bigball:1048576, /my_product/cust/IN:1048576, /apex/com.android.rkpd:41943040, /apex/com.android.tethering:41943040, /apex/com.android.crashrecovery:41943040, /apex/com.android.profiling:41943040, /apex/com.android.healthfitness:41943040, /apex/com.android.mediaprovider:41943040, /apex/com.android.virt:41943040, /apex/com.android.os.statsd:41943040, /apex/com.android.wifi:41943040, /apex/com.android.devicelock:41943040, /apex/com.android.ipsec:41943040, /apex/com.android.extservices:41943040, /apex/com.android.uprobestats:41943040, /apex/com.android.art:41943040, /apex/com.android.vndk.v33:44040192, /apex/com.android.resolv:41943040, /apex/com.android.cellbroadcast:41943040, /apex/com.android.sdkext:41943040, /apex/com.android.adbd:41943040, /apex/com.android.adservices:41943040, /apex/com.android.i18n:41943040, /apex/com.android.conscrypt:41943040, /apex/com.android.neuralnetworks:41943040, /apex/com.android.runtime:41943040, /apex/com.android.ondevicepersonalization:41943040, /apex/com.android.apex.cts.shim:41943040, /apex/com.android.media.swcodec:41943040, /apex/com.android.uwb:41943040, /apex/com.android.compos:44040192, /apex/com.android.tzdata:41943040, /apex/com.android.permission:41943040, /apex/com.android.configinfrastructure:41943040, /apex/com.android.scheduling:41943040, /apex/com.android.media:41943040, /apex/com.android.appsearch:41943040] Line 25450: 09-04 15:51:19.561963 1754 1754 I PackageManager: /data/apex/decompressed/com.android.adbd@360527520.decompressed.apex changed; collecting certs Line 25451: 09-04 15:51:19.563661 1754 1754 E PackageManagerServiceUtilsExtImpl: Fix up user restrict data of pkg: com.google.android.adbd Line 26299: 09-04 15:51:20.981292 1754 1754 D PackageManager: No files in app dir /apex/com.android.adbd/priv-app Line 26300: 09-04 15:51:20.981371 1754 1754 D PackageManager: No files in app dir /apex/com.android.adbd/app Line 27643: 09-04 15:51:22.158920 1754 1754 D OverlayManager: -> Updating overlay: target=com.google.android.adbd overlays=[OverlayPaths { resourceDirs = [/product/overlay/NavigationBarModeGestural/NavigationBarModeGesturalOverlay.apk], overlayPaths = [/product/overlay/NavigationBarModeGestural/NavigationBarModeGesturalOverlay.apk, /data/resource-cache/com.android.systemui-neutral-siVV.frro, /data/resource-cache/com.android.systemui-accent-tejr.frro, /data/resource-cache/com.android.systemui-dynamic-ysNR.frro] }] userId=0 Line 36832: 09-04 15:51:24.145889 1754 1976 I UsbDeviceManager: failed to write to /sys/class/android_usb/android0/f_rndis/ethaddr Line 36833: 09-04 15:51:24.146098 1754 1976 D UsbPortManager: Querying USB Gadget HAL version Line 36856: 09-04 15:51:24.151901 1754 1976 I UsbPortManager: USB Gadget HAL HIDL present Line 36867: 09-04 15:51:24.154788 1754 1928 I UsbDeviceManager: Usb gadget hal service started android.hardware.usb.gadget@1.0::IUsbGadget default Line 36873: 09-04 15:51:24.156186 1754 1976 D UsbDeviceManager: getInstance done Line 36893: 09-04 15:51:24.161777 1754 1875 I UsbDeviceManager: USB Gadget HAL HIDL version: 11 Line 36896: 09-04 15:51:24.162098 1754 1976 I UsbDeviceManager: mResetUsbGadgetDisableDebounce:false connected:1configured:1 Line 36897: 09-04 15:51:24.162260 1754 1875 I UsbDeviceManager: handleMessage MSG_UPDATE_STATE mConnected:true mConfigured:true Line 36902: 09-04 15:51:24.163208 1754 1875 I UsbDeviceManager: processing MSG_GET_CURRENT_USB_FUNCTIONS Line 36904: 09-04 15:51:24.163264 1754 1875 I UsbDeviceManager: updating mCurrentFunctions Line 36905: 09-04 15:51:24.163293 1754 1875 I UsbDeviceManager: mCurrentFunctions:4applied:1 Line 36908: 09-04 15:51:24.163397 1754 1875 D UsbDeviceManager: UsbBootInfo: [mSystemReady: false, mBootCompleted: false, mConnected: true, mConfigured: true, mCurrentUsbFunctionsReceived: true, mPendingBootBroadcast: true, mScreenLocked: true, screenUnlockedFunctions: mtp, isAdbEnabled: false] Line 36931: 09-04 15:51:24.166970 1754 1976 D UsbPortManager: Querying USB HAL version Line 36939: 09-04 15:51:24.168834 1754 1976 I UsbPortManager: USB HAL AIDL present Line 36947: 09-04 15:51:24.171554 1754 1976 D UsbPortManager: getInstance done Line 36962: 09-04 15:51:24.173683 1754 1966 I UsbPortManager: all: opID:1 successful Line 53160: 09-04 15:51:26.574846 1754 1963 D UsbDeviceManager: systemReady Line 53178: 09-04 15:51:26.579173 1754 1875 D UsbDeviceManager: UsbBootInfo: [mSystemReady: true, mBootCompleted: false, mConnected: true, mConfigured: true, mCurrentUsbFunctionsReceived: true, mPendingBootBroadcast: true, mScreenLocked: true, screenUnlockedFunctions: mtp, isAdbEnabled: true] Line 53187: 09-04 15:51:26.580817 1754 1843 I UsbPortManager: AIDL UsbDataStatus:1 Line 53188: 09-04 15:51:26.580934 1754 1843 I UsbPortManager: ClientCallback AIDL V1: port0 Line 53197: 09-04 15:51:26.582173 1754 1875 I UsbPortManager: USB port added: port=UsbPort{id=port0, supportedModes=dual, supportedContaminantProtectionModes=0, supportsEnableContaminantPresenceProtection=false, supportsEnableContaminantPresenceDetection=false, supportsComplianceWarnings=false, status=UsbPortStatus{connected=true, currentMode=ufp, currentPowerRole=sink, currentDataRole=device, supportedRoleCombinations=[source:host, sink:device], contaminantDetectionStatus=0, contaminantProtectionStatus=0, usbDataStatus=enabled, isPowerTransferLimited=false, powerBrickConnectionStatus=unknown, complianceWarnings=[], plugState=0, displayPortAltModeInfo=null}, canChangeMode=true, canChangePowerRole=false, canChangeDataRole=false, connectedAtMillis=24070, lastConnectDurationMillis=0 Line 53253: 09-04 15:51:26.591677 1754 1843 I UsbPortManager: all: opID:1 successful Line 69468: 09-04 15:51:29.851905 1754 1878 V UsbDeviceManager: onKeyguardStateChanged: isShowing:false secure:false user:0 Line 75381: 09-04 15:51:31.033122 1754 1754 I UsbDeviceManager: updateHostState UsbPort{id=port0, supportedModes=dual, supportedContaminantProtectionModes=0, supportsEnableContaminantPresenceProtection=false, supportsEnableContaminantPresenceDetection=false, supportsComplianceWarnings=false status=UsbPortStatus{connected=true, currentMode=ufp, currentPowerRole=sink, currentDataRole=device, supportedRoleCombinations=[source:host, sink:device], contaminantDetectionStatus=0, contaminantProtectionStatus=0, usbDataStatus=enabled, isPowerTransferLimited=false, powerBrickConnectionStatus=unknown, complianceWarnings=[], plugState=0, displayPortAltModeInfo=null} Line 88057: 09-04 15:51:33.353751 1754 1878 D UsbDeviceManager: boot completed Line 88169: 09-04 15:51:33.380805 1754 1875 D UsbDeviceManager: MSG_BOOT_COMPLETED Line 88170: 09-04 15:51:33.380953 1754 1875 D UsbDeviceManager: UsbBootInfo: [mSystemReady: true, mBootCompleted: true, mConnected: true, mConfigured: true, mCurrentUsbFunctionsReceived: true, mPendingBootBroadcast: true, mScreenLocked: false, screenUnlockedFunctions: mtp, isAdbEnabled: true] Line 88171: 09-04 15:51:33.380990 1754 1875 D UsbDeviceManager: finishBoot all flags true Line 88173: 09-04 15:51:33.381324 1754 1875 D UsbDeviceManager: broadcasting Intent { act=android.hardware.usb.action.USB_STATE flg=0x31100000 (has extras) } extras: Bundle[{host_connected=false, connected=true, unlocked=true, adb=true, mtp=true, configured=true}] Line 88207: 09-04 15:51:33.391465 1754 1875 D UsbDeviceManager: UsbFunc: [functions: mtp, forceRestart: false, mCurrentFunctionsApplied: true, mCurrentFunctions: mtp] Line 88208: 09-04 15:51:33.391681 1754 1875 D UsbDeviceManager: updateMtpFunction , mtpEnabled: true, ptpEnabled: false, mIsMtpServiceBound: false Line 88209: 09-04 15:51:33.391763 1754 1875 D UsbDeviceManager: Binding to MtpService Line 88440: 09-04 15:51:33.433186 1754 1875 D UsbDeviceManager: Unbinding from MtpService Line 88635: 09-04 15:51:33.450666 1754 1875 E UsbDeviceManager: Binding to MtpService failed Line 88664: 09-04 15:51:33.460049 1754 1875 W AdbDebuggingManager: Ignoring tag 'keyStore'. Not recognized. Line 88714: 09-04 15:51:33.466588 1754 1875 I AdbDebuggingManager: startAdbDebuggingThread ref=1 Line 88714: 09-04 15:51:33.466588 1754 1875 I AdbDebuggingManager: startAdbDebuggingThread ref=1 Line 88735: 09-04 15:51:33.473686 1754 3618 D AdbDebuggingManager: Entering thread Line 88736: 09-04 15:51:33.473788 1754 3618 D AdbDebuggingManager: Creating socket Line 88744: 09-04 15:51:33.474221 1754 3618 E AdbDebuggingManager: Caught an exception opening the socket: java.io.IOException: No such file or directory Line 88745: 09-04 15:51:33.474269 1754 3618 D AdbDebuggingManager: Closing socket Line 88773: 09-04 15:51:33.478547 1754 1875 D AdbDebuggingManager: adbd socket disconnected Line 88773: 09-04 15:51:33.478547 1754 1875 D AdbDebuggingManager: adbd socket disconnected Line 94028: 09-04 15:51:34.205634 3688 3688 D vold_prepare_subdirs: Setting up mode 771 uid 0 gid 1000 context u:object_r:apex_module_data_file:s0 on path: /data/misc_ce/0/apexdata/com.android.adbd Line 94690: 09-04 15:51:34.457411 1754 3674 W PackageManager: Skipping preparing app data for com.google.android.adbd Line 95349: 09-04 15:51:34.505920 1754 3618 D AdbDebuggingManager: Closing socket Line 95351: 09-04 15:51:34.506252 1754 1875 D AdbDebuggingManager: adbd socket disconnected Line 95351: 09-04 15:51:34.506252 1754 1875 D AdbDebuggingManager: adbd socket disconnected Line 95870: 09-04 15:51:34.565537 1754 1895 V UsbDeviceManager: onKeyguardStateChanged: isShowing:false secure:false user:0 Line 99064: 09-04 15:51:35.506385 1754 3618 D AdbDebuggingManager: Creating socket Line 99065: 09-04 15:51:35.508371 1754 3618 E AdbDebuggingManager: Caught an exception opening the socket: java.io.IOException: No such file or directory Line 99066: 09-04 15:51:35.508403 1754 3618 D AdbDebuggingManager: Closing socket解析log
09-05
clear all; close all; clc; %% 基本参数设置 M = 100; % 码元数量 L = 100; % 每码元采样点数 fs = 2000; % 模拟信号采样频率 (Hz) Rb = 1000; % 数字信号码元速率 (bps) Ts_digital = 1/Rb; % 数字码元间隔 dt = Ts_digital/L; % 系统采样间隔 % 载波参数 fc = 2000; % 载波频率 2kHz % 信道参数 SNR_dB = 15; % 信噪比 (dB) %% 1. 生成两路模拟信号 % 计算模拟信号时间向量 TotalT_analog = M * Ts_digital; % 模拟信号总时长 t_analog = 0:1/fs:TotalT_analog-1/fs; % 模拟信号时间向量 % 第一路信号: 正弦波 + 噪声 f1 = 50; % 信号频率 50Hz signal1 = 0.8*sin(2*pi*f1*t_analog) + 0.1*randn(size(t_analog)); % 第二路信号: 方波 f2 = 20; % 信号频率 20Hz signal2 = 0.5*square(2*pi*f2*t_analog, 40) + 0.2*cos(2*pi*5*t_analog); % 多路信号波形 figure('Name', '多路信源波形', 'NumberTitle', 'off'); subplot(2,1,1); plot(t_analog, signal1, 'b', 'LineWidth', 1.5); title('第一路模拟信号 (正弦波)'); xlabel('时间 (s)'); ylabel('幅度'); grid on; axis tight; subplot(2,1,2); plot(t_analog, signal2, 'r', 'LineWidth', 1.5); title('第二路模拟信号 (方波)'); xlabel('时间 (s)'); ylabel('幅度'); grid on; axis tight; %% 2. PCM编码 (8位) % 采样模拟信号 sample_indices = round(linspace(1, length(t_analog), M)); sampled_signal1 = signal1(sample_indices); sampled_signal2 = signal2(sample_indices); % 归一化到0-255范围 (8位) normalized1 = floor((sampled_signal1 + 1) * 127.5); normalized2 = floor((sampled_signal2 + 1) * 127.5); % 确保值在0-255范围内 normalized1(normalized1 < 0) = 0; normalized1(normalized1 > 255) = 255; normalized2(normalized2 < 0) = 0; normalized2(normalized2 > 255) = 255; % 转换为8位二进制 pcm_signal1 = dec2bin(normalized1, 8); pcm_signal2 = dec2bin(normalized2, 8); % 将PCM编码转换为二进制流 binary_stream1 = []; binary_stream2 = []; for i = 1:size(pcm_signal1, 1) binary_stream1 = [binary_stream1, pcm_signal1(i,:) - '0']; end for i = 1:size(pcm_signal2, 1) binary_stream2 = [binary_stream2, pcm_signal2(i,:) - '0']; end % 显示PCM编码波形 figure('Name', 'PCM编码波形', 'NumberTitle', 'off'); subplot(2,1,1); plot_bits = min(100, length(binary_stream1)); % 限制绘图点数 stairs(1:plot_bits, binary_stream1(1:plot_bits), 'LineWidth', 1.5); title('第一路信号PCM编码'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; subplot(2,1,2); plot_bits = min(100, length(binary_stream2)); stairs(1:plot_bits, binary_stream2(1:plot_bits), 'LineWidth', 1.5); title('第二路信号PCM编码'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; %% 3. 信道编码 (汉明码 7,4) % 汉明码编码函数 hamming_encoded1 = hamming_encode(binary_stream1); hamming_encoded2 = hamming_encode(binary_stream2); % 显示信道编码波形 figure('Name', '信道编码波形', 'NumberTitle', 'off'); subplot(2,1,1); plot_bits = min(100, length(hamming_encoded1)); stairs(1:plot_bits, hamming_encoded1(1:plot_bits), 'LineWidth', 1.5); title('第一路信号汉明码编码'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; subplot(2,1,2); plot_bits = min(100, length(hamming_encoded2)); stairs(1:plot_bits, hamming_encoded2(1:plot_bits), 'LineWidth', 1.5); title('第二路信号汉明码编码'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; %% 4. 时分多路复用 % 交替两路信号 multiplexed_signal = []; min_length = min(length(hamming_encoded1), length(hamming_encoded2)); for i = 1:min_length multiplexed_signal = [multiplexed_signal, hamming_encoded1(i), hamming_encoded2(i)]; end % 显示复用信号 figure('Name', '信道传输波形', 'NumberTitle', 'off'); plot_bits = min(200, length(multiplexed_signal)); stairs(1:plot_bits, multiplexed_signal(1:plot_bits), 'LineWidth', 1.5); title('时分多路复用信号'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; %% 5. 创建数字系统时间向量 total_bits = length(multiplexed_signal); TotalT_digital = total_bits * Ts_digital; % 数字信号总时长 t_digital = 0:dt:TotalT_digital; % 数字系统时间向量 if length(t_digital) > total_bits * L t_digital = t_digital(1:total_bits*L); % 确保时间向量长度匹配 end %% 6. 2ASK调制 % 复制每个比特L次 baseband = repelem(multiplexed_signal, L); % 确保baseband长度与时间向量匹配 if length(baseband) > length(t_digital) baseband = baseband(1:length(t_digital)); elseif length(baseband) < length(t_digital) t_digital = t_digital(1:length(baseband)); end % 生成载波 carrier = cos(2*pi*fc*t_digital(1:length(baseband))); % 2ASK调制 ask_signal = baseband .* carrier; % 显示调制信号 figure('Name', '2ASK调制信号', 'NumberTitle', 'off'); subplot(2,1,1); plot(t_digital(1:min(2000, length(ask_signal))), ask_signal(1:min(2000, length(ask_signal))), 'b', 'LineWidth', 1); title('2ASK调制信号'); xlabel('时间 (s)'); ylabel('幅度'); grid on; subplot(2,1,2); zoom_samples = min(200, length(ask_signal)); % 只显示前200个点 plot(t_digital(1:zoom_samples), ask_signal(1:zoom_samples), 'b', 'LineWidth', 1); title('2ASK调制信号 (放大)'); xlabel('时间 (s)'); ylabel('幅度'); grid on; %% 7. 信道传输 (加入高斯白噪声) noisy_signal = awgn(ask_signal, SNR_dB, 'measured'); % 显示加噪信号 figure('Name', '信道加入噪声后波形', 'NumberTitle', 'off'); subplot(2,1,1); plot(t_digital(1:min(2000, length(noisy_signal))), noisy_signal(1:min(2000, length(noisy_signal))), 'b', 'LineWidth', 1); title('加入高斯白噪声后的信号'); xlabel('时间 (s)'); ylabel('幅度'); grid on; subplot(2,1,2); zoom_samples = min(200, length(noisy_signal)); plot(t_digital(1:zoom_samples), noisy_signal(1:zoom_samples), 'b', 'LineWidth', 1); title('加入高斯白噪声后的信号 (放大)'); xlabel('时间 (s)'); ylabel('幅度'); grid on; %% 8. 接收端处理 % 带通滤波器设计 bpFilt = designfilt('bandpassfir', 'FilterOrder', 100, ... 'CutoffFrequency1', fc-500, 'CutoffFrequency2', fc+500, ... 'SampleRate', 1/dt); % 应用带通滤波器 filtered_signal = filtfilt(bpFilt, noisy_signal); % 显示带通滤波后的信号 figure('Name', '接收端滤波器后波形', 'NumberTitle', 'off'); subplot(2,1,1); plot(t_digital(1:min(2000, length(filtered_signal))), filtered_signal(1:min(2000, length(filtered_signal))), 'b', 'LineWidth', 1); title('带通滤波后的信号'); xlabel('时间 (s)'); ylabel('幅度'); grid on; subplot(2,1,2); zoom_samples = min(200, length(filtered_signal)); plot(t_digital(1:zoom_samples), filtered_signal(1:zoom_samples), 'b', 'LineWidth', 1); title('带通滤波后的信号 (放大)'); xlabel('时间 (s)'); ylabel('幅度'); grid on; % 相干解调 demod_signal = filtered_signal .* carrier(1:length(filtered_signal)); % 低通滤波器设计 lpFilt = designfilt('lowpassfir', 'FilterOrder', 100, ... 'PassbandFrequency', Rb/2, 'StopbandFrequency', Rb, ... 'SampleRate', 1/dt); % 应用低通滤波器 demod_filtered = filtfilt(lpFilt, demod_signal); % 显示解调信号 figure('Name', '解调后波形', 'NumberTitle', 'off'); subplot(3,1,1); plot(t_digital(1:min(2000, length(demod_signal))), demod_signal(1:min(2000, length(demod_signal))), 'b', 'LineWidth', 1); title('相干解调后的信号'); xlabel('时间 (s)'); ylabel('幅度'); grid on; subplot(3,1,2); plot(t_digital(1:min(2000, length(demod_filtered))), demod_filtered(1:min(2000, length(demod_filtered))), 'r', 'LineWidth', 1.5); title('低通滤波后的信号'); xlabel('时间 (s)'); ylabel('幅度'); grid on; % 抽样判决 sampled_signal = demod_filtered(round(L/2):L:end); received_bits = sampled_signal > 0.5; % 截取与发送相同长度的比特流 if length(received_bits) > length(multiplexed_signal) received_bits = received_bits(1:length(multiplexed_signal)); else multiplexed_signal = multiplexed_signal(1:length(received_bits)); end % 显示抽样判决后的信号 subplot(3,1,3); plot_bits = min(200, length(received_bits)); stairs(1:plot_bits, received_bits(1:plot_bits), 'm', 'LineWidth', 1.5); title('抽样判决后的数字信号'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; %% 9. 分路 received_signal1 = received_bits(1:2:end); received_signal2 = received_bits(2:2:end); % 确保长度匹配 min_length = min(length(received_signal1), length(hamming_encoded1)); received_signal1 = received_signal1(1:min_length); hamming_encoded1 = hamming_encoded1(1:min_length); min_length = min(length(received_signal2), length(hamming_encoded2)); received_signal2 = received_signal2(1:min_length); hamming_encoded2 = hamming_encoded2(1:min_length); % 显示分路信号 figure('Name', '多路信源解调波形', 'NumberTitle', 'off'); subplot(2,1,1); plot_bits = min(100, length(received_signal1)); stairs(1:plot_bits, received_signal1(1:plot_bits), 'b', 'LineWidth', 1.5); title('第一路解调信号'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; subplot(2,1,2); plot_bits = min(100, length(received_signal2)); stairs(1:plot_bits, received_signal2(1:plot_bits), 'r', 'LineWidth', 1.5); title('第二路解调信号'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; %% 10. 信道译码 (汉明码 7,4) decoded_signal1 = hamming_decode(received_signal1); decoded_signal2 = hamming_decode(received_signal2); % 确保长度匹配 min_length = min(length(decoded_signal1), length(binary_stream1)); decoded_signal1 = decoded_signal1(1:min_length); binary_stream1 = binary_stream1(1:min_length); min_length = min(length(decoded_signal2), length(binary_stream2)); decoded_signal2 = decoded_signal2(1:min_length); binary_stream2 = binary_stream2(1:min_length); % 显示信道译码波形 figure('Name', '信道译码波形', 'NumberTitle', 'off'); subplot(2,1,1); plot_bits = min(100, length(decoded_signal1)); stairs(1:plot_bits, decoded_signal1(1:plot_bits), 'b', 'LineWidth', 1.5); title('第一路汉明码译码'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; subplot(2,1,2); plot_bits = min(100, length(decoded_signal2)); stairs(1:plot_bits, decoded_signal2(1:plot_bits), 'r', 'LineWidth', 1.5); title('第二路汉明码译码'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); grid on; %% 11. PCM译码 % 将二进制流转换为十进制 decoded_bytes1 = reshape(decoded_signal1(1:floor(length(decoded_signal1)/8)*8), 8, [])'; decoded_bytes2 = reshape(decoded_signal2(1:floor(length(decoded_signal2)/8)*8), 8, [])'; digital_values1 = bin2dec(char(decoded_bytes1 + '0')); digital_values2 = bin2dec(char(decoded_bytes2 + '0')); % 转换为模拟信号 recovered_signal1 = (digital_values1 / 127.5) - 1; recovered_signal2 = (digital_values2 / 127.5) - 1; % 插值恢复连续信号 recovery_time = (0:length(recovered_signal1)-1) * Ts_digital; continuous_time = t_analog; interp_signal1 = interp1(recovery_time, recovered_signal1, continuous_time, 'spline'); interp_signal2 = interp1(recovery_time, recovered_signal2, continuous_time, 'spline'); % 显示恢复信号 figure('Name', 'PCM译码波形', 'NumberTitle', 'off'); subplot(2,1,1); plot(continuous_time, interp_signal1, 'b', 'LineWidth', 1.5); hold on; stem(recovery_time, recovered_signal1, 'r', 'filled'); title('第一路信号PCM译码恢复'); xlabel('时间 (s)'); ylabel('幅度'); legend('恢复信号', '采样点'); grid on; axis tight; subplot(2,1,2); plot(continuous_time, interp_signal2, 'b', 'LineWidth', 1.5); hold on; stem(recovery_time, recovered_signal2, 'r', 'filled'); title('第二路信号PCM译码恢复'); xlabel('时间 (s)'); ylabel('幅度'); legend('恢复信号', '采样点'); grid on; axis tight; %% 12. 误码率分析 % 计算原始信号与接收信号的比特差异 original_bits = [multiplexed_signal]; if length(original_bits) > length(received_bits) original_bits = original_bits(1:length(received_bits)); else received_bits = received_bits(1:length(original_bits)); end % 计算误码率 bit_errors = sum(original_bits ~= received_bits); total_bits = length(original_bits); bit_error_rate = bit_errors / total_bits; % 计算信道编码前后的误码率 original_data = [binary_stream1, binary_stream2]; received_data = [decoded_signal1(1:length(binary_stream1)), decoded_signal2(1:length(binary_stream2))]; if length(original_data) > length(received_data) original_data = original_data(1:length(received_data)); else received_data = received_data(1:length(original_data)); end data_errors = sum(original_data ~= received_data); data_error_rate = data_errors / length(original_data); % 显示结果 fprintf('通信系统性能分析:\n'); fprintf('总传输比特数: %d\n', total_bits); fprintf('信道编码前误码数: %d\n', data_errors); fprintf('信道编码前误码率: %.4f\n', data_error_rate); fprintf('信道编码后误码数: %d\n', bit_errors); fprintf('信道编码后误码率: %.4f\n', bit_error_rate); fprintf('信道编码纠错能力: %.2f%%\n', (data_errors - bit_errors)/max(1,data_errors)*100); % 显示误码位置 figure('Name', '误码分析', 'NumberTitle', 'off'); subplot(2,1,1); plot_bits = min(200, length(original_bits)); stem(1:plot_bits, original_bits(1:plot_bits), 'b', 'filled'); hold on; error_positions = find(original_bits(1:plot_bits) ~= received_bits(1:plot_bits)); stem(error_positions, original_bits(error_positions), 'r', 'filled'); title('原始发送比特流 (红色为误码位置)'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); legend('正确比特', '错误比特'); grid on; subplot(2,1,2); stem(1:plot_bits, received_bits(1:plot_bits), 'g', 'filled'); hold on; stem(error_positions, received_bits(error_positions), 'r', 'filled'); title('接收比特流 (红色为误码位置)'); xlabel('比特位置'); ylabel('比特值'); ylim([-0.1 1.1]); legend('接收比特', '错误比特'); grid on; %% 汉明码编码函数 function encoded = hamming_encode(data) % (7,4)汉明码编码 encoded = []; for i = 1:4:length(data) % 获取4位数据 start_idx = i; end_idx = min(i+3, length(data)); block = data(start_idx:end_idx); % 如果不足4位,补零 if length(block) < 4 block = [block, zeros(1, 4-length(block))]; end % 计算校验位 p1 = mod(block(1) + block(2) + block(3), 2); p2 = mod(block(1) + block(3) + block(4), 2); p3 = mod(block(2) + block(3) + block(4), 2); % 组合为7位码字 encoded = [encoded, block(1), block(2), block(3), block(4), p1, p2, p3]; end end %% 汉明码解码函数 function decoded = hamming_decode(data) % (7,4)汉明码解码 decoded = []; for i = 1:7:length(data) % 获取7位码字 start_idx = i; end_idx = min(i+6, length(data)); block = data(start_idx:end_idx); % 如果不足7位,补零 if length(block) < 7 block = [block, zeros(1, 7-length(block))]; end % 提取数据和校验位 d1 = block(1); d2 = block(2); d3 = block(3); d4 = block(4); p1 = block(5); p2 = block(6); p3 = block(7); % 计算校验子 s1 = mod(p1 + d1 + d2 + d3, 2); s2 = mod(p2 + d1 + d3 + d4, 2); s3 = mod(p3 + d2 + d3 + d4, 2); % 错误定位和纠正 error_pos = s1*1 + s2*2 + s3*4; if error_pos > 0 && error_pos <= 7 % 纠正错误 block(error_pos) = mod(block(error_pos) + 1, 2); end % 提取原始数据 decoded = [decoded, block(1:min(4, end_idx-start_idx+1))]; end end上述代码输出PCM译码波形质量较差,请进行优化
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值