Converting a coloumn of characters into number for logistic regression
1 view (last 30 days)
Show older comments
I have a coloumn that has Pass or Fail.
I want to assign Pass as 1 and Fail as zero for enntire coloumn.
a=['pass';'fail'; 'pass';'fail';'fail';'pass']
a =
6×4 char array
'pass'
'fail'
'pass'
'fail'
'fail'
'pass'
%Desired output
6×4 char array
1
0
1
0
0
1
% is this code correct???
for i=1:size(a,1)
if a(i)=='pass'
a(i)=1
else
a(i)=0
end
See Also
Categories
Find more on Linear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!