1x1 cell array dimension mismatch

Dear All,
It seems to be an easy question but has wasted my time for a couple of days! I have a 1x1 cell structure array that I would like to put data_path of two different files in it. I have two string matrices each containing one of these two files. I seem to not to be able to tell MATLAB to put both files in the same cell array, and I keep getting "subscripted assignment dimension mismatch". here is the example:
% for k=1:35 % cell.array.one.by.one(k)={firstFilePath(k,1) secondFilePath(k,2)}; %end
subscripted assignment dimension mismatch
Thanks in advance for your inputs!

댓글 수: 3

Arman
Arman 2012년 3월 17일
for k=1:35
cell.array.one.by.one(k) = {firstFilePath(k,1) secondFilePath(k,2)};
end
Oleg Komarov
Oleg Komarov 2012년 3월 17일
what class is firstFilePath?
type
whos firstFilePath(k,1)
Also don't call your sructure as cell... because it's already a builtin function.
Last thing, why are you nesting fieldnames like that?
cell.array.one.by.one(k)
this is a non scalar structure in a structure in a structure in a structure in a structure.
IN STRUCT PTION
Arman
Arman 2012년 3월 17일
class is cell. The reason for such a complicated structure is that I'm working with SPM for fMRI analysis, in batch scripting you need to have such a "structure in structure" and nesting.

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2012년 3월 17일

0 개 추천

I'm not sure what the 35 is for but if you have a 1x1 cell array, ca, and you want to put two strings in it that are of different lengths the only way I know how to do it is to put the two strings into a structure and then put the structure into a cell.
structFilenames.filename1 = filename1;
structFilenames.filename2 = filename2;
ca = {structFilenames};
celldisp(ca);
(I tried putting the strings into a 1x2 cell array and then putting that cell array into a single cell but it seemed not to work - it ended up creating a 2x1 cell array instead of a single cell with the 1x2 cell array inside it.)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

질문:

2012년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by