how to store all my result in the same table

hello..i need help plzz I want to store all my result in the same table..
*....................... T = zeros(3);
for i=1:numel(stats)
mark_i=mark == i;
mark_i_ends =bwmorph(mark_i,'endpoints');
[row,col]=find(mark_i_ends);
plot(col,row,'r.','markersize',5);
dist=sqrt((row(1)-row(2))^2 + (col(1)-col(2))^2);
bwdist=bwdistgeodesic(mark_i,col(1),row(1),'quasi-euclidean');
path=max(bwdist(:));
tortuosity=path/dist;
T(i,:,:,:) = [col,row,tortuosity];
end
*............................................
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
(line 56)
T(i,:,:,:) = [col,row,tortuosity];

Answers (1)

You define T as a 1D vector of 3 elements. Then you try to assign 3 elements to a 3D volume of a 4 dimensional array. You can't do that.
Preallocate T:
T = zeros(numel(stats), 3);
Then in the loop
T(i, :) = [col, row, tortuosity];
Do not call your variable bwdist! bwdist is a built-in function and I wouldn't be surprised if bwdistgeodesis used in internally, but you've blown it away by calling your variable that. Likewise, DO NOT CALL YOUR VARIABLE PATH! Again, it's a built-in function. You'll run into trouble if you destroy it like you're doing.

2 Comments

thanks for you help...but bwdist works fine for me....the problem I have left is the storage
T = zeros(numel(stats),3);
for i=1:numel(stats)
mark_i=mark == i;
mark_i_ends =bwmorph(mark_i,'endpoints');
[row,col]=find(mark_i_ends);
plot(col,row,'r.','markersize',5);
dist=sqrt((row(1)-row(2))^2 + (col(1)-col(2))^2);
bwdist=bwdistgeodesic(mark_i,col(1),row(1),'quasi-euclidean');
path=max(bwdist(:));
tortuosity=path/dist;
T(i,:) = [col,row,tortuosity];
end
%
Dimensions of matrices being concatenated are not consistent.
Error in tortio (line 42) T(i,:) = [col,row,tortuosity];
I'm truly stunned by your first statement where you ignored my advice not to name variables after built in functions. You didn't directly ask another question, but I'm not sure you would take my advice if I offered any. Good luck.

Sign in to comment.

Asked:

on 10 Aug 2014

Commented:

on 10 Aug 2014

Community Treasure Hunt

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

Start Hunting!