using logical to make a logical matrix

3 Ansichten (letzte 30 Tage)
Tor Fredrik Hove
Tor Fredrik Hove am 18 Okt. 2011
I wanted to make a logical matrix which consists of some true and some false. This is my attempt to create a 2 rows 3 columns matrix with only true in the forst row and only false in the second row:
vec=[true(1:3);false(1:3)]
but the answer in matlab became something different:
>> vec=[true(1:3);false(1:3)]
vec(:,:,1) =
1 1
0 0
vec(:,:,2) =
1 1
0 0
vec(:,:,3) =
1 1
0 0
what did I do wrong?
  1 Kommentar
Jan
Jan am 18 Okt. 2011
"true(1:3)" means "true([1, 2, 3])"!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Daniel Shub
Daniel Shub am 18 Okt. 2011
So close
vec = [true(1, 3); false(1, 3)]

Weitere Antworten (0)

Kategorien

Mehr zu App Building 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