how to assign 1 to negative value and 0 to positive values in dataset
Ältere Kommentare anzeigen
i have data in excel consist of 404 rows and 19 columns. In data there are some negative values and positive values so i have to assign '1' to all values in data which is less than zero and '0' to all values which is more than or equal to zero.
Antworten (1)
Andrei Bobrov
am 3 Feb. 2016
n = xlsread('name_your_xlsx_file.xlsx');
out = n < 0;
6 Kommentare
kumud alok
am 4 Feb. 2016
James Tursa
am 4 Feb. 2016
Bearbeitet: James Tursa
am 4 Feb. 2016
Why don't you think it is working? What code are you running and what results are you getting that don't seem correct?
kumud alok
am 4 Feb. 2016
Bearbeitet: Guillaume
am 4 Feb. 2016
kumud alok
am 4 Feb. 2016
Walter Roberson
am 4 Feb. 2016
The one minor difference between the pseudocode and Andrei's code is that the pseudocode assigns a 1 and 0 of some unknown data type, whereas Andrei's code assigns 1 and 0 of type logical . logical values and numeric values are transparently converted for most purposes, but from time to time you might need to specifically convert logical values to some other data type such as by using out = double(n<0) if you need double precision 0 and double precision 1 as the values.
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!