# Create two cell arrays referring to another cell array

1 view (last 30 days)
luca on 15 Oct 2019
Answered: SaiDileep Kola on 25 Mar 2021
Given the following arrays and cell
SP= [1 2 3 4 6 9];
M = [0 1 1 1 0 1 1 1 1];
T= [20 34 34 20 34 20 25 34 25];
G = {[1 2 2 1 3 4 9 9 6 1 3 3 2 1 2 4 3 ; 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85],[ 2 2 3 3 4 9 4 9 6 4 9 3 3 2 2 4 ; 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 ]};
I want to iterate on G considering every time a different element indicated in SP.
Considering the first cell.
I want to create two cell that refer to each cell of G. The first cell to create is called R and the second one is called V. Every time I meet a diversity I want to write a certain value in each cell.
Consider the element diversity 1 in the first cell of G, I want to calculate the folliwing things:
in R{1,1}{1,1} I would like to have a matrix where the first raw contain the diversity 1 in G{1,1}. so the first raw will be 1,1,1,1. and the second raw will be the one indicated in the picture.
in V{1,1}{1,1}I would like to have a matrix where the first raw contain the diversity 1 in G{1,1}. so the first raw will be 1,1,1,1. and the second raw will be the one indicated in the picture.
As you can see, a part for the first time, then the iteration formula is always the same.
For element diversity 2 the same.
in R{1,1}{1,2} I would like to have a matrix where the first raw contain the diversity 1 in G{1,1}. so the first row will be 2,2,2,2. and the second row will be the one indicated in the picture.
in V{1,1}{1,2}I would like to have a matrix where the first row contain the diversity 1 in G{1,1}. so the first row will be 2,2,2,2. and the second raw will be the one indicated in the picture. there is a typo, is 112 and not 113
I would like to do this for all the cell and all the diversity,
May someone can help me?

SaiDileep Kola on 25 Mar 2021
Check if this might be of any help