MATLAB Answers

I am getting an error "Cell contents reference from a non-cell array object"

1 view (last 30 days)
jeffin
jeffin on 9 Jul 2015
Commented: Guillaume on 10 Jul 2015
Kindly help me. Thanks in advance
Error in MCI (line 3) MVF_row = MVF{1};

  0 Comments

Sign in to comment.

Answers (3)

dpb
dpb on 9 Jul 2015
The short answer is don't use the curly braces around the '1' but what is MVF intended to be? The LHS variable name makes it look like you're intending more than a single element but we can't tell from the tiny code snippet with no context you've posted. If it is an array and you do want the first row, that would be MVF(1,:) but it would seem that a general expression would be more likely desired but at this point there's no klew as to what that might be (or even if am on right track or not...)

  2 Comments

jeffin
jeffin on 10 Jul 2015
Sir, i want MVF to be a cell array object. The error is this:
Error in MCI (line 3)
MVF_row = MVF{1};
Error in Test_Single_FramNew (line 49)
im_interp = MCI(im_prev_pad,im_next_pad,MVF,params);
MCI is a function which goes like this,
function im_interp = MCI(im_prev_pad,im_next_pad,MVF,params)
MVF_row = MVF{1};
MVF_col = MVF{2};
im_rows = params.im_rows;
im_cols = params.im_cols;
[block_rows,block_cols] = size(MVF{1});
...
When i change MVF{1} to MVF(1) its causing error in further lines like size(MVF{1}). What i actually want is MVF to be a cell array.ie, MVF{1}.
In the previous function of MCI i have used the MVF in this fashion:
motionVect = vectors;
aaa = v1*v2
blk1 = motionVect(1,:)
B2 = reshape(blk1,[aaa/v1,aaa/v2])
MVF_blka = B2';
MVF = MVF_blka;
% MVFc = MVF_blka
blk2 = motionVect(2,:);
C2 = reshape(blk2,[aaa/v1,aaa/v2]);
MVF_blkb= C2';
MVF(:,:,2) = MVF_blkb;
Kindly Help me out.
Guillaume
Guillaume on 10 Jul 2015
Well, if you want MVF to be a cell array, create it as such.
Until you explain what you're trying to do we can't help you do it right.

Sign in to comment.


Guillaume
Guillaume on 9 Jul 2015
Well, the error is fairly clear, you're trying to access a cell of a cell array but MVF is not a cell array.
Possibly, you meant:
MVF_row = MVF(1);
Or possibly, you meant something else entirely.

  0 Comments

Sign in to comment.


Image Analyst
Image Analyst on 10 Jul 2015
It looks like MVF is a 3-dimensional array. Is it a color image? So you will never use braces with it. See the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F You say you want it to be a cell array. Why? For what purpose? And even if you did want that, that is not how you created it. You created it as a standard numerical 3D array when you did this:
MVF = MVF_blka;
MVF(:,:,2) = MVF_blkb;
So you have a 3D array with two planes or slices. It is not a cell array. So when you do this
MVF_row = MVF{1};
you're trying to get the first cell of a cell array. But it's not a cell array. You call it MVF_row like you're trying to get 1 row. Well 1 row will have two vectors in it - one from the top plane and one from the bottom plane. I'm not really sure what you're after here. You can get each plane like this:
MVF_plane1 = MVF(:,:,1);
MVF_plane2 = MVF(:,:,2);
Now if you wanted, say, row #42 from plane #1, you'd do this:
MVF_row = MVF_plane1(42,:);
If you wanted, say, column #13 from plane #2, you'd do this:
MVF_col = MVF_plane2(:, 13);

  1 Comment

jeffin
jeffin on 10 Jul 2015
Sir, i used the steps
---------------------------------------------------
motionVect = vectors;
aaa = v1*v2
blk1 = motionVect(1,:)
B2 = reshape(blk1,[aaa/v1,aaa/v2])
MVF_blka = B2';
MVF = MVF_blka;
% MVFc = MVF_blka
blk2 = motionVect(2,:);
C2 = reshape(blk2,[aaa/v1,aaa/v2]);
MVF_blkb= C2';
MVF(:,:,2) = MVF_blkb
---------------------------------------
in my code below to reshape my matrix in the following form:ie,
motionVect =size(2 X 5N). // orginal size (step)
motionVect(1)= (1 X 5N) and motionVect(2)=1 X 5N // Intermediate step
MVF(1) = [1 ... N; N+1 ... 2N; 2N+1 ... 3N; 3N+1 ... 4N; 4N+1 ... 5N] // expected reshape ------------------(1)
MVF(2) = [1 ... N; N+1 ... 2N; 2N+1 ... 3N; 3N+1 ... 4N; 4N+1 ... 5N] // expected reshape
which i achieved using the above code.
Then in my code i called the next function MCI which is as follows:
function im_interp = MCI(im_prev_pad,im_next_pad,MVF,params)
MVF_row = MVF{1};
MVF_col = MVF{2};
im_rows = params.im_rows;
im_cols = params.im_cols;
[block_rows,block_cols] = size(MVF{1});
...
MVF_right{1} = -MVF{1};
MVF_right{2} = -MVF{2} ...
end.
There are so many places in this function i use MVF{}. changing MVF{} to MVF() is causing me trouble/error in other functions. Therefore i felt that it is good to initialize the first MVF(1) and MVF(2) ie eqn(1) in the form of cell array.
Kindly help me. I am finding it difficult because i'am new to cell array concept. Thanks in advance.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!