MATLAB: Error: Undefined function ‘plus’ for input arguments of type ‘cell’

addadditioncellerrorplus

Dear All
I am facing such error when I am trying to add cells. OM+M+w
Following is the result of whos:
Name Size Bytes Class Attributes
M 975x1 73842 cell
Name Size Bytes Class Attributes
OM 975x1 74000 cell
Name Size Bytes Class Attributes
w 975x1 73482 cell
Actually I am trying to read a text file.
=====================================================================
24652 1996-063A ARABSAT-2B
Launched: 1996-11-13 (318) Start Date: 1996-06-12 (164)
Decayed: Stop Date: 2003-12-20 (354)
=====================================================================
1 24652U 96063A 96318.74847837 -.00000020 00000-0 00000+0 0 14
2 24652 3.9929 210.6007 7281127 177.7757 190.4436 2.27277888 06
1 24652U 96063A 96319.62211352 -.00000020 00000-0 00000+0 0 31
2 24652 3.9929 210.3183 7284735 178.4392 185.2995 2.27373269 12
1 24652U 96063A 96319.62351606 .00008082 00000-0 30835-2 0 24
2 24652 3.9764 210.1654 7280836 178.5436 186.6267 2.27380102 20
1 24652U 96063A 96319.62356237 .00009638 00000-0 38025-2 0 37
2 24652 3.9632 210.3512 7280110 178.4006 186.6625 2.27374993 25
1 24652U 96063A 96320.05952563 -.00002597 00000-0 -98092-3 0 63
2 24652 3.9623 210.1661 7275699 178.7092 185.6294 2.27896863 39
1 24652U 96063A 96320.49676119 -.00000127 00000-0 10000-4 0 72
2 24652 3.9626 209.9743 7275563 179.0821 184.3511 2.27899371 49
1 24652U 96063A 96320.49712798 .00000100 00000-0 10000-3 0 53
2 24652 3.9640 209.9130 7275537 179.1425 184.6535 2.27900057 39
<end of file>
fid=fopen('2B.txt');
A=textscan(fid,'%s','HeaderLines',5);
Data=reshape(A{1}(1:end-3,:),9,[])';
fclose(fid);
l1=Data(1:2:end,:);
l2=Data(2:2:end,:);
OM=l2(:,4); % RAAN
ecc=l2(:,5); %Eccentricity
w=l2(:,6); %Argument of perigee
M=l2(:,7); %mean anomaly
FF=OM+w+M;
So I just want to know how can i add OM , w and M

Best Answer

You cannot add cell arrays, just as the error states. Cell arrays are a little different than numerical arrays, and you need to be aware of those differences when dealing with them. And by the way, what is i? There is no variable i listed in your workspace, so you will get the imaginary unit. Is that what you wanted?
What do you want to do? Say we have these:
A = {2 3 4 5}; % Two cell arrays.
B = {6 7 8 9};
What do you want to do? Do you want:
C = {8 10 12 14} % C = cellfun(@plus,A,B,'Un',0)
or were you thinking more like this:
C = {2 3 4 5;6 7 8 9} % C = cat(1,A,B)
Be specific in what you want, and give a thorough description of what is in each element of your cell arrays. For example, is each element a scalar, as I show above, or is each element a numeric array? If the latter, do the sizes match between the elements of the cells you wish to add?