How to change nonzero values to 1 within a table?

How to change nonzero values to '1' within a table? for all columns at once.

 Accepted Answer

tempTable = table2array(myTable);
tempTable(tempTable~=0)=1;
myTable = array2table(tempTable);

More Answers (0)

Categories

Asked:

on 19 Dec 2019

Commented:

on 20 Dec 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!