Error using sum Dimension argument must be a positive integer scalar, a vector of unique positive integers, or 'all'.
32 次查看(过去 30 天)
显示 更早的评论
I am attempting to do this calculation:
VRTemp=((sum(ATretreive{1,7:10})/4)*100)-273;
But I then receive this error:
Error using sum
Dimension argument must be a positive integer scalar, a vector of unique positive integers, or 'all'.
I first use:
ATdata=uitable(uifigure,'ColumnName',{'Test date'; 'Accel S/N' ;'Accel_0' ;'Accel_90'; 'Accel_180'; 'Accel_270';...
'Temp_0' ;'Temp_90'; 'Temp_180' ;'Temp_270'},'Data',ATdatac);
ATretreive= get(ATdata,'Data');
in order to obtain and extract the data.
How should I correct this error?
0 个评论
回答(1 个)
Walter Roberson
2020-7-8
sum(ATretreive{1,7:10})
ATretrieve is a cell . Using index {1,7:10} is cell expansion, and is going to produce a comma-separated list, just as if you had invoked
sum(ATretreive{1,7}, ATretreive{1,8}, ATretreive{1,9}, ATretreive{1,10})
That is too many non-option arguments for sum()
I suspect what you want is
mean(cell2mat(ATretrieve(1,7:10)), 2) * 100 - 273
but you need to figure out whether you want the sum to be by row or by column; the version with mean() here is by row under the guess that the division by 4 corresponds to division by number of columns.
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!