how to find the indexing for the following code.

1 visualización (últimos 30 días)
jaah navi
jaah navi el 19 de Feb. de 2019
Comentada: jaah navi el 19 de Feb. de 2019
clear all;
clc
A=[1 2;
3 4;
5 6;
7 8;
9 10;
11 12;
13 14;
15 16];
C=size(A,1)
B=1:3
D= randi(C,1)
I want to perform the randi(C,1) with respect to 1st index of B followed by 2nd index ,then 3rd index.
Could anyone please help me on this.

Respuesta aceptada

KSSV
KSSV el 19 de Feb. de 2019
A=[1 2;
3 4;
5 6;
7 8;
9 10;
11 12;
13 14;
15 16];
C=size(A,1)
B=1:3
for i = B
D= randi(C,i)
end
  1 comentario
jaah navi
jaah navi el 19 de Feb. de 2019
ok.
B=1 2 3;
But i want to have the result in the following manner
In for loop i=1
D=randi(C,1)
=8 % D should displays the single number with respect to first element of i
i=2
D=randi(C,2)
=5 % D should display the single number with respect to second element of i but not in 2x2.
i=3
D=randi(C,3)
= 4%D should display the single number with respect to third element of i but not in 3x3.
Could you please help me on this.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by