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

60 views (last 30 days)
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?

Answers (1)

Walter Roberson
Walter Roberson on 8 Jul 2020
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.

Community Treasure Hunt

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

Start Hunting!