replace values in an array with certain numbers
Show older comments
I have an array (very long array) with values varying from 1 to 20 (with decimal values in between). What i want to do is the following:
if the values in my array are between 0 and 1, then replace with number 500;
if the values are between 1 and 2, then replace with 1000;
if the values are between 2 and 3, then replace with 1500;
..... and so on.
How could i do this, thanks in advance :)
Accepted Answer
More Answers (1)
x = 2*rand(10, 1);
edges = 0:2;
d = discretize(x, edges, [500, 1000]);
results = table(x, d, 'VariableNames', ["Raw data", "Discretized value"])
1 Comment
Fadel Raad
on 16 Dec 2020
Categories
Find more on Matrices and Arrays 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!