MATLAB: How to have a loop if for a column in a table

columniftable

I have a table with many columns… I want to iterate into one column, that have many numbers valores. is there someone that can help me?
the pseudocode is
if table.column > number
table.new_column= 'Ok'
else
table.this_new column='nok'
finally i wil have a new columns with ok and nok depending of the valor of the column

Best Answer

You don't need a for loop, use arrayfun(),
words = {'nok', 'ok'};
table.newColumn = arrayfun(@(x) words((x>number)+1), table.column);