Azzera filtri
Azzera filtri

how to find the indexing for the following code.

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

KSSV
KSSV il 19 Feb 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 Commento
jaah navi
jaah navi il 19 Feb 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.

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by