Error calculating mean when variable inputs are decimals between 0 and 1
显示 更早的评论
I am trying to calculate the mean of 2 invidiual variables within a large cell array of data. My work around for all other variables has been to index the specific value needed and then do the math. For example:
var1 = cell2mat(myArray(5,1));
var2 = cell2mat(myArray(6,1));
avg_var = mean(var1, var2);
However, this has only worked so far when the variables I pull have been whole integers. When trying to replicate this process on another data set, whose values are all between 0 and 1, I get the error:
Error using sum
Dimension argument must be a positive integer scalar, a vector of unique positive integers, or 'all'.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
Here are my example values:
leftRT = 0.5819;
rightRT = 0.6710;
avg_RT = mean(leftRT, rightRT);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!