How to compare blank spaces in arrays?

1 ビュー (過去 30 日間)
Luis Angel Manriquez Ramirez
Luis Angel Manriquez Ramirez 2022 年 11 月 28 日
回答済み: Jonas 2022 年 11 月 28 日
Hello every one, I'm working on a little project on app designer where I need to do something like this:
Say I have two arrays of strings of the same size but the second has some 'blanks' as follows:
a=["red","blue","green","yellow"];
b=["orange","","","purple"];
How can I get a new array 'c' with the words from array 'a' that are at the same position as `blanks' in array 'b'?
the result would be:
c=["blue","green"];
Thanks for reading!

回答 (1 件)

Jonas
Jonas 2022 年 11 月 28 日
use this
a=["red","blue","green","yellow"];
b=["orange","","","purple"];
c=a(b=="")
ans = 1×2 string array
"blue" "green"

カテゴリ

Find more on Characters and Strings in Help Center and File Exchange

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by