Calling data with using rand command

1 Ansicht (letzte 30 Tage)
FURKAN CEVAHIR
FURKAN CEVAHIR am 5 Feb. 2019
Kommentiert: KSSV am 5 Feb. 2019
Hi, I want to call data in the matrix by using string which is defined by rand command.
A=[1 2]
B=[2 3]
C=[3 5]
corners = 'ABC'
randompick = corners(randi(numel(corners)))
disp(randompick)
randompick(1)
Here I cant get any first row numbers of the A, B, and C.
What's wrong in this script?
Thanks.
Desired answer is
Same as what A(1), B(1) or C(1) give after randomly chosing.
  2 Kommentare
madhan ravi
madhan ravi am 5 Feb. 2019
what‘s the desired output?
FURKAN CEVAHIR
FURKAN CEVAHIR am 5 Feb. 2019
Same as what A(1), B(1) or C(1) give after randomly chosing.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 5 Feb. 2019
A=[1 2
2 3
3 5] ;
corners = 1:size(A,1) ;
randompick = corners(randi(numel(corners)))
disp(randompick)
idx = randompick(1) ;
iwant = A(idx,1)
  6 Kommentare
FURKAN CEVAHIR
FURKAN CEVAHIR am 5 Feb. 2019
My apologize, thanks..
KSSV
KSSV am 5 Feb. 2019
No issues.....No aplogizes.......you are welcome.......

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Numeric Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by