Effacer les filtres
Effacer les filtres

how to find the indexing for the following code.

1 vue (au cours des 30 derniers jours)
jaah navi
jaah navi le 19 Fév 2019
Commenté : jaah navi le 19 Fév 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.

Réponse acceptée

KSSV
KSSV le 19 Fév 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 commentaire
jaah navi
jaah navi le 19 Fév 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by