Categorical Data Handling | Part 2 | Machine Learning | MATLAB
Simple code :
k=["France","Spain","Germany"];
l=[2,1,0];
g=Data2.Country;
number=zeros(length(g),1);
for i=1:length(k)
rs=ismember(g,k(i));
number(rs)=l(i);
end
or you can follow this also:
k={'France','Spain','Germany'};
l=[2,1,0];
g=Data2.Country;
number=zeros(length(g),1);
for i=1:length(k)
rs=ismember(g,k{i});
number(rs)=l(i);
end
Free program: https://www.matlabcoding.com Free Support: castorclasses2014@gmail.com Live Support: t.me/matlabirawen Like us: https://www.facebook.com/matlabirawen/ Join us: https://www.facebook.com/groups/MATLA... MATLAB Book for the beginner: https://amzn.to/3fTfmTa
Free program: https://www.matlabcoding.com Free Support: castorclasses2014@gmail.com Live Support: t.me/matlabirawen Like us: https://www.facebook.com/matlabirawen/ Join us: https://www.facebook.com/groups/MATLA... MATLAB Book for the beginner: https://amzn.to/3fTfmTa
No comments