how convert string in struct with 0/1
3 次查看(过去 30 天)
显示 更早的评论
>> 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 个评论
采纳的回答
Stephen23
2023-11-3
S = struct('FS',{'Si','No','Si','Rank','No'})
Z = nan(size(S));
[X,Y] = ismember({S.FS},{'No','Si'});
Z(X) = Y(X)-1
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!