hi, i want partition largest interval(contain more than element) to 4 interval , and partition the second biggest interval to 3 interval,and partition the third biggest interval to 3 interval, But the rest remains the same.retaining orderofinterval
1 次查看(过去 30 天)
显示 更早的评论
% i have n values z1,z2 , ...,zn this is numerical values . i partition this to seven interval as following and calculate the length for every interval(length for nonzero element), the interval contain more than element from z1,...zn i need partition it to 4 subinterval have same length While retaining the order and the second largest interval partition to 3 subinterval have same length and the third interval partition to 2 subinterval have same length and the remaining interval Remain the same . In the end we get to 13 interval .
n = 50;
z = 1000 * rand(1, n); % Sample data
a=min(z);
b=max(z);
k =7; % such that k is the number of intervals
L= (max(z)-min(z))/k; %such that L is length of each interval
% Here is my solution:
intK = round(k);
uMatrix = [linspace(a, b-L, intK)', linspace(a+L, b, intK)']
for i=1:n
for j=1:k
if (uMatrix(j,1)<=z(i)&z(i)<=uMatrix(j,2))
uMatrix(j,1,i)=z(i);
end
end
end
for i=1:k
temp1=uMatrix(i,:,:);
%whos temp1
temp2 = nonzeros(temp1);
%whos temp2
temp3 = length(temp2);
%w hos temp3
le(i)=temp3;
end
2 个评论
John D'Errico
2016-8-27
编辑:John D'Errico
2016-8-27
Maybe the reason there was no answer is because your question is so confusingly stated. But asking the same question over and over again won't get any better response.
It is not at all obvious to me what you want to do here. So slow down. Try making your goals clearer, more easily understood.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!