Concatenating columns from a for loop.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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{:});
0 Kommentare
Antworten (1)
Jan
am 17 Feb. 2015
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?
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!