Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
i am a newb on matlab. why i've got some error with this. please help me
조회 수: 1 (최근 30일)
이전 댓글 표시
clear all; clc
[x,s] = xlsread("nilaifreq.csv");
freq_list = freq_list >= 0.04 & freq_list < 0.15;
% sum all power value with freq. range from LF criteria
lf_data = pow_list(freq_list >= 0.04 & freq_list < 0.15);
sum_lf_data = sum(lf_data);
C = [C char(10) 'sum all power value with freq, range from 0.04 to 0.15 for LF criteria...'];
% sum all power value with freq. range from HF criteria
hf_data = pow_list(freq_list >= 0.15 & freq_list <= 0.4);
sum_hf_data = sum(hf_data);
C = [C char(10) 'sum all power value with freq, range from 0.15 to 0.4 for LF criteria...'];
% ratio LF/HF
ratio_lf_hf = sum_lf_data / sum_hf_data;
C = [C char(10) 'ratio LF/HF...'];
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/756909/image.png)
please help me, i want to sum the data power just include in frequency 0.04 to 0.15. i write the code, but got error.
댓글 수: 2
DGM
2021년 10월 3일
You'll have to mention what error you're actually getting.
% placeholder data
freq_list = rand(10,1)/2;
pow_list = (1:10).';
C = [];
% all this does is convert freq_list to a logical vector
% which breaks everything
%freq_list = freq_list >= 0.04 & freq_list < 0.15; % don't need this
% sum all power value with freq. range from LF criteria
lf_data = pow_list(freq_list >= 0.04 & freq_list < 0.15);
sum_lf_data = sum(lf_data);
C = [C char(10) 'sum all power value with freq, range from 0.04 to 0.15 for LF criteria...'];
% sum all power value with freq. range from HF criteria
hf_data = pow_list(freq_list >= 0.15 & freq_list <= 0.4);
sum_hf_data = sum(hf_data);
C = [C char(10) 'sum all power value with freq, range from 0.15 to 0.4 for HF criteria...'];
% ratio LF/HF
ratio_lf_hf = sum_lf_data / sum_hf_data;
C = [C char(10) 'ratio LF/HF...'];
Idk if there's some problem with how the file is imported or something, but this runs.
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!