Create a matrix whereas values can be -180 0 or 200

1 Ansicht (letzte 30 Tage)
André Pacheco
André Pacheco am 18 Dez. 2012
Hello
Is like the title says: i would be able to create a certain matrix 1:24 where i can only have -180, 0 or 200 sort randomly.
P.E.
[-180 200 0 0 0 200 200 -180 -180 0 ....]
Thanks in advance

Akzeptierte Antwort

Laura Proctor
Laura Proctor am 18 Dez. 2012
I'm sure there's a more elegant solution, but here's one:
x = randi(3,1,24)-1;
x(x==1) = -180;
x(x==2) = 200;

Weitere Antworten (1)

Image Analyst
Image Analyst am 18 Dez. 2012
Try this:
a = int16(randi(3, 1, 24))
a(a==1) = -180;
a(a==2) = -0;
a(a==3) = -200;
  1 Kommentar
Image Analyst
Image Analyst am 18 Dez. 2012
For a more general solution you can use intlut(), in the Image Processing Toolbox.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with MATLAB 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