MATLAB: Deleting strings in a list

elementliststringstrings

So I have a list containing strings like this
test = {'3.jpg', '4.jpg', '5.jpg', '6.jpg'};
I want to delete the specific entry with the name '4.jpg' completely, not just be left with ' ' – which is what the function erase does erase(test{2}, '4.jpg'). And in my project I do not know where this specific element is located.
for i = 1:length(test)
if strcmp(test{i}, '4.jpg') == 1
""Do something that deletes element i""
end
end
Thanks in advance

Best Answer

test = {'3.jpg', '4.jpg', '5.jpg', '6.jpg'};
test(strcmp(test, '4.jpg')) = []