MATLAB: spilliting an array into n parts and then joining them again forming a histogram
Show older comments
i am new to matlab.
lets say i have an array a = [1:1:1000]
i have to divide this into 50 parts 1-20; 21-40 .... 981-1000.
i am trying to do it this way.
E=1000X
a=[1:E]
n=50
d=E/n
b=[]
for i=0:n
b(i)=a[i:d]
end
but i am unable to get the result
and the second part is i am working is , depending on another result, say if my answer is 3 , the first split array should have a counter and that should be +1, if the answer is 45 the 3rd split array's counter should be + 1 and so on and in the end i have to make a histogram of all the counters.
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 21 Oct 2012
Edited: Azzi Abdelmalek
on 21 Oct 2012
a=1:1000
out=reshape(a,20,[])
% If you want to put a result in a cell array
res=arrayfun(@(x) out(:,x),1:1000/20,'un',0)
1 Comment
Ashish paul
on 22 Oct 2012
Categories
Find more on MATLAB 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!