Error using sum Dimension argument must be a positive integer scalar, a vector of unique positive integers, or 'all'.

조회 수: 56 (최근 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?

답변 (1개)

Walter Roberson
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.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by