Replacing single values in a matrix with 1x09 doubles
Show older comments
Hi there, Im really stuck on this and could use some help, so I have a matrix:
designs = [ 0 1 2 3 4 5 6 0 6 5 4 3 2 1 0;
0 2 6 4 1 3 5 0 5 3 1 4 6 2 0;
0 3 2 5 1 6 4 0 4 6 1 5 2 3 0;
0 4 1 5 6 2 3 0 3 2 5 6 1 4 0;
0 5 3 6 1 4 2 0 2 4 1 3 6 5 0;
0 6 5 4 3 2 1 0 1 2 3 4 5 6 0];
and essentially I want to replace each value of every number (i.e. all the ones) with successive 1x09 doubles in a 12x09 array
blockOrderCat =
1×6 cell array
{12×9 double} {12×9 double} {12×9 double} {12×9 double} {12×9 double} {12×9 double}
So the goal is for the first instance of 1 in 'designs' to be replaced with the first 1x09 double in blockOrderCat{1}, the second 1 to be replaced with the second 1x09 double in blockOrderCat{1} etc etc.
I know I have to iterate through both, but I don't know where to begin really.
Thank you so much!
4 Comments
the cyclist
on 24 Mar 2021
Clarifying question: The array designs is a 6x15 numeric array. Do you want the final output to be a 6x31 numeric array, because what used to be a single element has been replaced with a 1x9 vector?
If not, what do you mean?
Matthew Peoples
on 24 Mar 2021
the cyclist
on 24 Mar 2021
And when counting the instances of "1" in the designs array, do you want to work your way across the rows, or down the columns.
In other words, is the "second 1" in the first row, or in the third column?
Matthew Peoples
on 24 Mar 2021
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!