could anyone help me to solve the issue in the following command
    3 views (last 30 days)
  
       Show older comments
    
    jaah navi
 on 23 Jun 2021
  
    
    
    
    
    Commented: Walter Roberson
      
      
 on 24 Jun 2021
            when i run the command 
B = arrayfun(@(N) randi(2,N), repelem((1:3).',5), 'uniform', 0) 
i am getting B =   15×1 cell array
    {[       1]}
    {[       1]}
    {[       1]}
    {[       2]}
    {[       2]}
    {2×2 double}
    {2×2 double}
    {2×2 double}
    {2×2 double}
    {2×2 double}
    {3×3 double}
    {3×3 double}
    {3×3 double}
    {3×3 double}
    {3×3 double} and the data inside are 
3
2
2
2
2
[1,1;1,1]
[1,1;2,1]
[1,3;3,1]
[3,1;1,3]
[1,1;1,1]
[1,1,3;1,2,2;1,2,1]
[3,2,2;3,1,3;1,2,3]
[1,2,2;1,3,1;1,2,3]
[3,1,1;3,3,1;3,2,3]
[3,2,1;3,1,1;3,2,1]
but I actually need B =
  15×1 cell array
    {1×1double}
    {1×1 double}
    {1×1 double}
    {1×1 double}
    {1×1 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×2 double}
    {1×3 double}
    {1×3 double}
    {1×3 double}
    {1×3 double}
    {1×3 double} containing the following values
3
2
2
2
2
[1,1]
[1,1]
[1,3]
[3,1]
[1,1]
[1,1,3]
[3,2,2]
[1,2,2]
[3,1,1]
[3,2,1]
could anyone please help me to get it.
0 Comments
Accepted Answer
  Walter Roberson
      
      
 on 23 Jun 2021
        B = arrayfun(@(N) randi(2,1,N), repelem((1:3).',5), 'uniform', 0) 
2 Comments
  Walter Roberson
      
      
 on 24 Jun 2021
				You have a fixed outcome, and you have no explainable reason for that particular outcome. You should just write static assignment statements.
Remember the fundamental rule of practical programming: get it working first, and worry about making it shorter or faster later. You have been held up for days trying to write these things in a compact way, when you could have just written something that got the required outcome and moved on to the next step.
More Answers (0)
See Also
Categories
				Find more on Multidimensional 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!