I want to calculate the avearge power of each channels , condition and frequency band

2 次查看(过去 30 天)
function test_spectra(spectra,pts,specfreqs,elcRegion)
avg_power=cell(length(elcRegion),6,2);
for i=1:length(elcRegion) %number of channals
for j=1:6 %condicion
for k=1:2 %band freqeuncy
for n=1:length(pts(:,1))
if pts(n,3)==j
sig_time=pts(n,3);
if pts(n,3)==1
rest_time=pts(n,3);
end
if k==1
avg_power(i,j,k)=bandpower(spectra(:,i,sig_time),1000,[12 30])/bandpower(spectra(:,i,rest_time),1000,[12 30]);
else
avg_power(i,j,k)=bandpower(spectra(:,i,sig_time),1000,[30 70])/bandpower(spectra(:,i,rest_time),1000,[30 70]);
end
end
end
end
end
end
figure()
histogram(avg_power(6,3,1),30)
end
this is the problam :
Conversion to cell from double is not possible.
thank you!!

回答(1 个)

Venkat Siddarth
Venkat Siddarth 2023-5-2
I understand that you are facing an issue in converting double to cell.You can achieve this using a function called num2cell .
%In this we will try to convert a vector of doubles to cell array using num2cell function
numArray=[1.1 2.2 3.3]; %vector of doubles.
%converting to cell array using the num2cell function
cellArray=num2cell(numArray)
cellArray = 1×3 cell array
{[1.1000]} {[2.2000]} {[3.3000]}
To know more about this function,checkout the following documentation:
I hope this resolves your issue
Regards,
Venkat Siddarth V

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by