Hey, I am having trouble indexing into string vectors
Ältere Kommentare anzeigen
I am having trouble indexing into string arrays using logical values. As an example:
res = ["ABC" , "DEF" , "GHI"]
tf = [ 1 0 1 ]
x = res(tf)
I expect MATLAB to return
x = ["ABC" , "GHI"]
however instead i get the following error
"Array indices must be positive integers or logical values."
Akzeptierte Antwort
Weitere Antworten (1)
Anna Case
am 27 Apr. 2020
0 Stimmen
tf = [1 3] is what you are looking for. If you open up the variable res, you will see "ABC" is in index 1 and "GHI" is in index 3.
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!