Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

i am a newb on matlab. why i've got some error with this. please help me

1 view (last 30 days)
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...'];
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 Comments
DGM
DGM on 3 Oct 2021
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.

Answers (0)

This question is closed.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!