Undefined function 'mtimes' for input arguments of type 'cell'.

I am having some trouble with obtaining a calculation. I first used:
radians=0;
Rs=1.00021697;
dRs=250;
SeattleG=32.17546;
GNOG=32.12536;
VSFR=cos(radians)*((ATretreive{1,3} - (ATretreive{1,5}))/(2*Rs)); %Vertical readings-scale factor
VBR=((ATretreive{1,3} + ATretreive{1,5})/(2*VSFR))*1000000; %Vertical readings-bias
VRTemp=(((ATretreive{1,7} + (ATretreive{1,8}) + (ATretreive{1,9}) + (ATretreive{1,10}))/4) *100)-273; %Vertical readings-temp
HBR=((ATretreive{1,4} + ATretreive{1,6})/(2*VSFR))*1000000; %Horizontal readings-bias
rmdData=importdata('AccelQuery.mat')
SERIAL_NUMBER={rmdData.('SERIAL_NUMBER')}
BIA_COF_0={rmdData.('BIA_COF_0')}
BIA_COF_1={rmdData.('BIA_COF_1')}
BIA_COF_2={rmdData.('BIA_COF_2')}
BIA_COF_3={rmdData.('BIA_COF_3')}
BIA_COF_4={rmdData.('BIA_COF_4')}
SF_COF_0={rmdData.('SF_COF_0')}
SF_COF_1={rmdData.('SF_COF_1')}
SF_COF_2={rmdData.('SF_COF_2')}
SF_COF_3={rmdData.('SF_COF_3')}
SF_COF_4={rmdData.('SF_COF_4')}
mergetables=table(SERIAL_NUMBER,BIA_COF_0,BIA_COF_1,BIA_COF_2,BIA_COF_3...
,BIA_COF_4,SF_COF_0,SF_COF_1,SF_COF_2,SF_COF_3,SF_COF_4);
uitdata=uitable(uifigure,'Data',mergetables);
uitdata.ColumnName={'Accel S/N' ;'BIA_COF_0'; 'BIA_COF_1'; 'BIA_COF_2'; 'BIA_COF_3' ;'BIA_COF_4';...
'SF_COF_0'; 'SF_COF_1'; 'SF_COF_2' ;'SF_COF_3' ;'SF_COF_4'};
BIA0=mergetables{app.AccelSNEditField == mergetables{:,1},2};
BIA1=mergetables{app.AccelSNEditField == mergetables{:,1},3};
BIA2=mergetables{app.AccelSNEditField == mergetables{:,1},4};
BIA3=mergetables{app.AccelSNEditField == mergetables{:,1},5};
BIA4=mergetables{app.AccelSNEditField == mergetables{:,1},6};
SF0=mergetables{app.AccelSNEditField == mergetables{:,1},7};
SF1=mergetables{app.AccelSNEditField == mergetables{:,1},8};
SF2=mergetables{app.AccelSNEditField == mergetables{:,1},9};
SF3=mergetables{app.AccelSNEditField == mergetables{:,1},10};
SF4=mergetables{app.AccelSNEditField == mergetables{:,1},11};
CalcBias=(BIA0+(BIA1*(VRTemp-20))+(BIA2*(VRTemp-20)^2)+(BIA3*(VRTemp-20)^3)+...
(BIA4*(VRTemp-20)^4))*(SeattleG/GNOG); %Calculated Bias
Then I get an error for CalcBias:
Undefined function 'mtimes' for input arguments of type 'cell'.
Any suggestions or resolutions?

回答(1 个)

Matrix multiplication isn't defined for a cell array. No arithmetic operators are. Unlike a double or single precision matrix, the elements in a cell array don't have to contain just numbers. They don't have to be scalars.
C = {'abcde', ones(2, 3, 4), magic(5); {'q'}, struct('abc', 'def'), []}
You can't multiply C by anything or anything by C.
A = C*[1 2; 3 4] % Throws an error
You can't multiply C(1, 3) by anything or anything by C(1, 3). C(1, 3) is itself a cell.
B = C(1, 3)*fliplr(eye(5)) % Throws an error
You can multiply C{1, 3} (which is a 5-by-5 matrix) by something with which it's compatible.
D = C{1,3}*fliplr(eye(5))

4 个评论

How should I modify the equation since most of the values are extracted from data?
I assume the BIA* variables are cell arrays. You probably want to extract the data inside the cell like I did in the line that assigns to D in my example.
If they aren't a simple cell array show us their structure.
celldisp(BIA0) % Assuming this isn't too long
or save one of them in a MAT-file and attach it to a comment.
Here is the attached file for BIA_COF_0

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Time Series Events 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by