How can I divide an interval in intervals with the same length?
조회 수: 32 (최근 30일)
이전 댓글 표시
Hello,
I have a point cloud and I would like to do a Matlab program, which calculates the mean of values of intervals, which have the same length. I don't know how I can begin that. Please, I need your help.
Maxime
댓글 수: 0
채택된 답변
Sean de Wolski
2011년 7월 8일
Here's an example of what might lead you to your end goal:
A = 1:64; %vector
B = mean(reshape(A,8,8),1); %mean of intervals 8 long.
Is this what you're looking for? If it's not please provide a small sample of input data/operation/expected output
댓글 수: 7
Sean de Wolski
2011년 7월 8일
Actually: use histc (second output argument) and accumarray to bin-> mean the values directly.
추가 답변 (2개)
Friedrich
2011년 7월 8일
Hi,
are you looking for something like this?
start_interval = 0;
end_interval = 10;
intervals = 20;
interval_length = (end_interval - start_interval)/intervals;
x = start_interval + (end_interval-start_interval)*rand(200,1);
y = rand(200,1);
plot(x,y,'*')
hold on
for i=1:intervals
left = start_interval + interval_length*(i-1);
right = start_interval + interval_length*i;
ind = x >= left & x < right;
m_y = mean(y(ind));
line( [left,right],[m_y,m_y], 'Color','r' );
line( [left,left], [-0.5,1.5] ,'Color','black')
end
hold off
simar
2011년 7월 8일
Probably you need to elaborate a bit more what exactly your problems is?
For this much all I can say is that you can use mean command in matlab for calculating mean of values. Use help mean to get a better insight of it.
Or
You can use this a=1 % this will represent you length of interval
b = zeros(size(X));
for n =1:length(X)-1
b(n) = (X(n)-X(n+1)>a)
end
z =find(b>a) % this will return all index for this is true
and then use something like this mean (X(z));
But for better understanding your problem, you must elaborate your problem.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Point Cloud Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!