replace values in an array with certain numbers
이전 댓글 표시
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 :)
채택된 답변
추가 답변 (1개)
x = 2*rand(10, 1);
edges = 0:2;
d = discretize(x, edges, [500, 1000]);
results = table(x, d, 'VariableNames', ["Raw data", "Discretized value"])
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!