use of strcmp with two conditions

조회 수: 5 (최근 30일)
Muazma Ali
Muazma Ali 2022년 7월 3일
답변: Muazma Ali 2022년 7월 3일
Hi
I am wondering whats wrong with this code:
filtered=(min_tabell(strcmp(min_tabell.best_salt_1_n_best_salt_2,'NH4Cl',:)||(strcmp(min_tabell.best_salt_1_n_best_salt_2,'NaCl',:))))
the error that I get
Undefined function or variable 'strcmp'.

답변 (2개)

DGM
DGM 2022년 7월 3일
편집: DGM 2022년 7월 3일
Just a guess, since I have no idea what your array content or size are.
strcmp() takes two arguments, but you're feeding it two arguments while simultaneously trying to index into it like an array.
things = {'b','a','NH4Cl'}
things = 1×3 cell array
{'b'} {'a'} {'NH4Cl'}
filtered_ok = strcmp(things,'NH4Cl')
filtered_ok = 1×3 logical array
0 0 1
filtered_bad = strcmp(things,'NH4Cl',:)
Unrecognized function or variable 'strcmp'.
If you're trying to select all columns of the selected rows in min_tabell, then do that outside the calls to strcmp().

Muazma Ali
Muazma Ali 2022년 7월 3일
No, maybe I shd have written wht the code was supposed to do: Filtered is a table that comes out after I have used strcmp in two conditions on min_tabell n then the question is whether it can be done with "or" symbol? Whether strcmp can be used two times including an "or" symbol

카테고리

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