Concatenating columns from a for loop.

조회 수: 4 (최근 30일)
Shaun
Shaun 2015년 2월 17일
편집: Shaun 2015년 2월 20일
Hi, So I have some code that creates a column of data in each run of a for loop. I want to concatenate those columns to build an array once the for loop has finished. So far I have....
vals = cell(size(images, 3), 2);
T2ind = cell(size(images, 1), 1);
T2 = cell(size(images, 1), size(images, 2));
for y = 1:size(images,1)
for x = 1:size(images,2)
if ((sum(images(y,x,:))/size(images, 3)) > 100)
for z = 1:size(images, 3)
echo = dat(z, 6);
imgVal = images(y,x,z);
vals(z,:) = {echo, imgVal};
end
f = fit(cell2mat(cellfun(@cell2mat, vals(:,1), 'UniformOutput', false)), cell2mat(vals(:,2)), 'exp1');
coeff = coeffvalues(f);
a= coeff(1);
b = coeff(2);
S1 = f(10);
S2 = S1/exp(1);
T2ind{x} = {((log(S2/a))/b)};
end
end
T2(y,:) = cat(1, T2ind{:});
end
The idea being that T2 will be my array of 256 by 256 data points constructed from the 256 T2ind columns. I get a subscripted assignment dimension mismatch error for T2. Any help would be great! Thanks!
Error:
Subscripted assignment dimension mismatch.
Error in T2_mapping (line 60)
T2(y, :) = cat(1, T2ind{:});

답변 (1개)

Jan
Jan 2015년 2월 17일
Please post a complete copy of the error message in every case. Thanks.
T2(y,:) = cat(1, T2ind{:});
The right hand side is a row vector, the left hand side a column vector. Are you sure you want to apply CAT here?
  댓글 수: 1
Shaun
Shaun 2015년 2월 17일
I've added the error code. So I want a set of columns (T2ind) to be concatenated into an array (T2). So,
T2(y,:) = cat(2, T2ind{:});
would be better? I tried that and got the same error. not sure if that's what you mean.

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

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by