create an array

6 views (last 30 days)
Hassan
Hassan on 30 Jun 2011
I wonder how I can make an array (200,400) with values 0 to 7 which randomly distributed? I apperciate your help.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 30 Jun 2011
rand(200,400)*7
  2 Comments
Hassan
Hassan on 30 Jun 2011
thanks but can you please show it with an example?

Sign in to comment.

More Answers (1)

Sean de Wolski
Sean de Wolski on 30 Jun 2011
szs = [20 20 30]; %sizes
vals = [1 0 2]; %values
C = cellfun(@(c,v)ones(c)*v,num2cell(szs),num2cell(vals),'uni',false);
M = blkdiag(C{:});
  3 Comments
Hassan
Hassan on 30 Jun 2011
thanks a lot Sean and Andrei.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!