필터 지우기
필터 지우기

how convert string in struct with 0/1

조회 수: 1 (최근 30일)
aldo
aldo 2023년 11월 3일
답변: Stephen23 2023년 11월 3일
>> class(Sis)
ans =
'struct'
>> size(Sis)
ans =
1 351
i access it using : Sis(1).FilterSkip
Sis.FilterSkip can to be "No" or "Si" or "Rank"
if Sis.FilterSkip ="No" i want to get 0.
.if Sis.FilterSkip="Si" i want to get 1
i want to create vector wih 0 or 1 using Sis.FilterSkip
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2023년 11월 3일
What should be the value when Sis.FilterSkip is "Rank"?
aldo
aldo 2023년 11월 3일
if it's "Rank" ignore value

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2023년 11월 3일
S = struct('FS',{'Si','No','Si','Rank','No'})
S = 1×5 struct array with fields:
FS
Z = nan(size(S));
[X,Y] = ismember({S.FS},{'No','Si'});
Z(X) = Y(X)-1
Z = 1×5
1 0 1 NaN 0

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by