Create two cell arrays referring to another cell array

조회 수: 2 (최근 30일)
luca
luca 2019년 10월 15일
답변: SaiDileep Kola 2021년 3월 25일
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?

답변 (1개)

SaiDileep Kola
SaiDileep Kola 2021년 3월 25일
Check if this might be of any help

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by