MATLAB: How to transfer a cell array content into ordinal values

ordinal values

i have a cell array of string content and i want to turn the contents of cell 2 into ordinal values according to the list shown below in 'clinicalVAL.png'
catnames = { 'stage i'; 'stage ia'; 'stage ii'; 'stage iia'; 'stage iib'; 'stage iic'; 'stage iii'; 'stage iiia';'stage iiib'; 'stage iiic'; 'stage iv'; 'stage iva'; 'stage ivb'};
valueset={1;2;3;4};
for i=1:217
B = categorical(Ystg{i}(2),catnames,valueset,'Ordinal',true);
end
I have tried this code but doesn't work and i want to do it programmatically and not manually; is it possible in MATLAB?
ERROR: Error using categorical
Creating an instance of the Abstract class 'categorical' is not allowed.

Best Answer

Hi Friends, I created this code and run it and is worked well, but i wonder if there is another more fast code that can do this job????
for i=1:217
if strcmpi(Ystg{i}(2),'stage i') || strcmpi(Ystg{i}(2),'stage ia')
Stage(i,1) = 1;
else if strcmpi(Ystg{i}(2),'stage ii') || strcmpi(Ystg{i}(2),'stage iia')|| strcmpi(Ystg{i}(2),'stage iib')|| strcmpi(Ystg{i}(2),'stage iic')
Stage(i,1) = 2;
else if strcmpi(Ystg{i}(2),'stage iii') || strcmpi(Ystg{i}(2),'stage iiia')|| strcmpi(Ystg{i}(2),'stage iiib')|| strcmpi(Ystg{i}(2),'stage iiic')
Stage(i,1) = 3;
else if strcmpi(Ystg{i}(2),'stage iv') || strcmpi(Ystg{i}(2),'stage iva')|| strcmpi(Ystg{i}(2),'stage ivb')
Stage(i,1) = 4;
end
end
end
end
end