필터 지우기
필터 지우기

Round values in cell array to n(10)?

조회 수: 7 (최근 30일)
Calabrese
Calabrese 2017년 8월 2일
편집: the cyclist 2017년 8월 2일
How to round the following...
cell = {15;26;37;48;50;68};
cell2 = roundn(cell,1)
to
cell2 = {20;30;40;50;50;70};
How would it change if I wanted to round just up or down and not to the nearest n(10)?

채택된 답변

the cyclist
the cyclist 2017년 8월 2일
편집: the cyclist 2017년 8월 2일
c = {15;26;37;48;50;68};
N = -1; % Digit to round to. N=-1 will round to tens. N=0 will round to nearest integer
c2 = cellfun(@(x)round(x,N),c)
Side note: It is a bad idea to name a variable with a MATLAB keyword such as "cell".

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by