I have a list of cells that contain string and i want to try to find if it contain a specify string. i have 4 possibility and on each of them i do something else. i can do in with if-else (a simple example add above). How i can do it but with switch?
a = {'pass' 1;'hp' 1;'C2C' 200; 'hC2C' 200; 'C2C TO' 534; 'hC2C' 534; 'C2C TO' 534; ... 'hp' 1001; 'pass' 1001; 'pass' 1001};d = [1 200 534 1001];for i=1:length(d) if sum(strcmp(a(cell2mat(a(:,2))==d(i)),'pass')) ~= 0 fprintf('It''s a Passive\n') elseif sum(strcmp(a(cell2mat(a(:,2))==d(i)),'C2C')) ~= 0 fprintf('It''s a C2C\n') elseif sum(strcmp(a(cell2mat(a(:,2))==d(i)),'C2C TO')) ~= 0 fprintf('It''s a C to C\n') endend
Best Answer