I want to add a definite fixed intervals between my input data

조회 수: 1 (최근 30일)
ANIL N R
ANIL N R 2022년 3월 30일
답변: ANIL N R 2022년 3월 31일
input
distance =[0 0 5 10 15 20];
I want to add 1m interval between the each inputs, if applicable.
Output
0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 .

채택된 답변

Arif Hoq
Arif Hoq 2022년 3월 30일
try this:
distance =[0 0 5 10 15 20];
C=cell(6,1);
for i=1:length(distance)-1
C{i}= distance(i):1:distance(i+1);
end
output=[C{:}];
output=[output(1) unique(output)]
output = 1×22
0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

추가 답변 (1개)

ANIL N R
ANIL N R 2022년 3월 31일
nn =[0 0 0 1 1 1 20 25 25 30 37 37 37 40];
Interval=[];
for j=1:numel(nn)
if (nn(j)==nn(numel(nn)))||(nn(j)==nn(j+1))
C{numel(Interval)+1}= nn(j);
else
C{numel(Interval)+1}= ((nn(j)):1:(nn(j+1)-1));
end
Interval=[C{:}];
end
Interval = 0 0 0 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 25 26 27 28 29 30 31 32 33 34 35 36 37 37 37 38 39 40

카테고리

Help CenterFile Exchange에서 Interpolating Gridded Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by