Filtering for variable amount of constraints

Hi Everyone,
I have the following problem: I want to filter a dataset for a number of constraints. However, this number of constraints is variable.
I have the follwing code:
%% Filter for cargo constraints
%Solution 1
Data.VCsuit = Data.VC(strcmp(Data.Cargotypes{3,1},Data.VC{:,6})==1 | strcmp(Data.Cargotypes{2,1},Data.VC{:,6})==1,:);
%Solution 2
for i = 1 : height(Data.Cargotypes)
Data.VCsuit = Data.VC(strcmp(Data.Cargotypes{i,1},Data.VC{:,6})==1,:);
end
the problem with solution 1 is the variable, the problem of solution 2 is that it overwrites the previous filter. All datasets are tables. How can I best approach this? The dataset is in the attachements.

 채택된 답변

Fabian Leede
Fabian Leede 2020년 11월 16일

0 개 추천

And some more trying fixed it. the final code for anyone in the future:
%% Filter for cargo constraints
Data.VCsuit = Data.VC(strcmp(Data.Cargotypes{2,1},Data.VC{:,6})==1,:);
for i = 3 : height(Data.Cargotypes)
temp = Data.VC(strcmp(Data.Cargotypes{i,1},Data.VC{:,6})==1,:);
Data.VCsuit = [Data.VCsuit;temp];
clear temp
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기

태그

질문:

2020년 11월 16일

답변:

2020년 11월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by