MATLAB: Create variable from cell array based on strings

cell arraystring

I have a cell array something like this…
if true
Var1=
'A' 6
'B' 7
'B' 7
'A' 8
'C' 10
'A' 9
'A' 3
end
I want to pull out the values into a new variable which correspond only to 'A'
I.e generate this variable
if true
Var2=
'A' 6
'A' 8
'A' 9
'A' 3
end

Best Answer

Var1={'A',6; ...
'B',7; ...
'B',7; ...
'A',8; ...
'C',10; ...
'A',9; ...
'A',3};
Var2=Var1(strcmpi(Var1(:,1),'A'),:)
Var2 =
'A' [6]
'A' [8]
'A' [9]
'A' [3]