strcmp: compare a string with a set of strings

조회 수: 2 (최근 30일)
alpedhuez
alpedhuez 2020년 6월 19일
편집: alpedhuez 2020년 6월 19일
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일
IsSpring=ismember('January',{'January','Feburary','March'})

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by