strcmp: compare a string with a set of strings

I have a table 'test'
month temperature
---
January
February
---
I want to create a new variable called 'season'. I want to define
spring={January, February, March}
and I want to write things like
strcmp(test.month(1),spring)==1
that is, I want to use compare one string with a set of strings and to return 1 if the string is equal to one of the set of strings. Please advise.

 採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 6 月 19 日

0 投票

IsSpring=ismember('January',{'January','Feburary','March'})

1 件のコメント

alpedhuez
alpedhuez 2020 年 6 月 19 日
編集済み: alpedhuez 2020 年 6 月 19 日
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

製品

タグ

質問済み:

2020 年 6 月 19 日

編集済み:

2020 年 6 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by