Logical Operator with cell
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Voss
on 14 Dec 2023
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 Comments
See Also
Categories
Find more on Encryption / Cryptography in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!