Logical Operator with cell
조회 수: 2 (최근 30일)
이전 댓글 표시
I have done this code and I would like to enshorten it. Do you have a suggestion?
Indexn = strfind(reg_freight_train(:,3),'ITC');
c = find(not(cellfun('isempty',Indexn)));
reg_train_LD_ita =reg_freight_train(c,:);
LOAD=str2double(reg_train_LD_ita(:,5:size(reg_train_LD_ita,2)));
Indexn = strfind(reg_freight_train(:,3),'ITD');
c = find(not(cellfun('isempty',Indexn)));
reg_train_LD_ita =reg_freight_train(c,:);
LOAD=[LOAD ; str2double(reg_train_LD_ita(:,5:size(reg_train_LD_ita,2)))];
Indexn = strfind(reg_freight_train(:,3),'ITH');
c = find(not(cellfun('isempty',Indexn)));
reg_train_LD_ita =reg_freight_train(c,:);
LOAD=[LOAD ; str2double(reg_train_LD_ita(:,5:size(reg_train_LD_ita,2)))];
댓글 수: 0
답변 (1개)
Voss
2023년 12월 14일
names = {'ITC','ITD','ITH'};
LOAD = [];
for ii = 1:numel(names)
LOAD = [LOAD; str2double(reg_freight_train(contains(reg_freight_train(:,3),names{ii}),5:end))];
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!