How can I find the maximum element of each column of a cell array
Show older comments
I have a cell array like this:
if true
ca={'x' 1 1 9 3;'y' 5 1 1 1; 'z' 5 7 5 9};
end
I have to find the max number of each column then divide all element of that column to maximum I wrote this code but it had errors:
if true
for j=2:3
max_column=max(ca(:,j));
for i=1:5
ca(i,j)= ca(i,j)/max_column;
end
end
disp(ca)
end
Please help me to edit this code. thanks in advance
Accepted Answer
More Answers (1)
Jos (10584)
on 5 May 2015
1 vote
Life would be much easier if you didn't have your data arranges like this in the first place. How did you get this cell array? I strongly suggest you reconsider your approach.
1 Comment
Yes!
Strangely it seems to be the people with the most awkward and bizarre nested data arrangements that insist that "this is the only way" to arrange it, and that "it has to be this way..."... usually followed up with some painful loops and a whole brace [sic] of braces, parentheses and brackets...
Sigh
Categories
Find more on Matrices and Arrays 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!