Info
此问题已关闭。 请重新打开它进行编辑或回答。
Error in locating a reference cell for calculations
1 次查看(过去 30 天)
显示 更早的评论
So far I have got this code:
%%=================================================
%%to find average power first use "find" function to find the first zero in
%%Fz, have the cell referenced
%%then use nanmean for average power(av_pwr)
%%use nanmin for peak power (peak_pwr)
%%=================================================
ref= find(data{i,1}(:,5)==0);
ref=ref(1);%returns all times zero occurs then extracts first time data is 0
peak_pwr(i,1) = nanmin (data {i,1}(1:ref,5));
%preak power in coloumn E1 in all data with reference to cell found
av_pwr(i,1)=nanmean(data{i,1}(1:ref,5));
%average power in coloumn E1 in all data with reference to cell found
I have tried to locate the first zero in column E1 and then use this as a reference cell to get the peak and average power. However it is coming up with this error:
Attempted to access ref(1); index out of bounds because numel(ref)=0.
Error in code (line 53) ref=ref(1);%returns all times zero occurs then extracts first time data is 0
anyone know how to get around this?
0 个评论
回答(1 个)
David Sanchez
2014-5-14
If you read the line:
Attempted to access ref(1); index out of bounds because numel(ref)=0.
you can see that
data{i,1}(:,5)==0
is never fulfilled and therefore, ref remains an empty array with no values in it.
When you tried to access its first value:
ref=ref(1)
the system complains (yields an error) because there is nor such an element. Since I do not have data, it is nor easy to tell whether any of its elements equals 0 in any moment.
5 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!