I have to import text file and then find the centroid value of the matrix
Show older comments
This is the code I wrote but it doesn't rum Please help me
for n = 1:5
data=['C:\Users\sunayana.chakradhar\Documents\MATLAB\Ascii12\f',num2str(n),'.txt'];
I= dlmread(data);
I=mean(I);
X_sum=sum(I,1); % sum of every column
Y_sum=sum(I,2); % sum of every row
X=1:120; % number of elements in x i
Y=1:120; % number of elements in y j
centX=sum((I(X,Y)*X_sum))/sum(I(X,Y));
disp centX
end
1 Comment
Walter Roberson
on 14 May 2013
Isn't this really the same matter as your other question http://www.mathworks.co.uk/matlabcentral/answers/75752-matrix-centroid-finding-using-data-in-a-text-file ? If so then you should post it there and delete this question.
Answers (0)
Categories
Find more on Text Data Preparation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!