首页 > 解决方案 > 如何将 Matlab 索引转换为 Python

问题描述

data_tp0 = xlsread(append(con,'_',treatment,string(hrt),'_t',string(tps(1)),'_analysis.xlsx'));
Time_tp0=data_tp0(:,1);

signal_tp0=(data_tp0(:,2));
% signal = sin(Time);   %%  Raw signal with time period of ~6.5 sec i.e. Freq = 1/6.5 = 0.15 Hz
L = length(Time_tp0);
Fs= L/max(Time_tp0);     % Sampling frequency                    
T = 1/Fs;             % Sampling period  


Y_tp0 = fft(signal_tp0);                          % Compute DFT of Signal and get real and imaginary components
P2_tp0 = abs(Y_tp0/L);                            % Whole spectrum
P1_tp0 = P2_tp0(1:L/2+1);                         % One-sided spectrum
P1_tp0(2:end-1) = 2*P1_tp0(2:end-1);              % Even-valued signal length L.

单边谱线是什么意思?具体来说

1:L/2+1 inside of the P2_tp0(1:L/2+1)

这个索引是什么意思?它在 python 中的等价物是什么?

同样,索引对于这行代码及其在 python 中的等价物意味着什么?

P1_tp0(2:end-1) = 2*P1_tp0(2:end-1)

标签: pythonmatlabindexing

解决方案


推荐阅读