How to divide a curve into 8 equal region along x axis?
3 次查看(过去 30 天)
显示 更早的评论
Hi. I am working with border irregularity. For this I have determined the irregularities in the curve. Here the 'stars' indicate the irregularities. I want to divide it into 8 parts so that if any part contains minimum one star I can count it as 1. So if all the 8 parts have stars in each,the value will be 8. So the final value will be of any between 0 to 8. How can I do this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/319189/image.bmp)
I have attached my code and the image.
采纳的回答
KSSV
2020-6-19
A = rand(1,100) ;
a = length(A) ;
n = 8 ;
% check whether data needed to be appended to reshape into n
b = n * ceil(a / n)-a ;
%
A = [A NaN(1,b)] ;
iwant = reshape(A,n,[]) ;
% plot
plot(iwant)
13 个评论
更多回答(1 个)
John D'Errico
2020-6-20
编辑:John D'Errico
2020-6-20
I am surely wasting my time (and yours) to answer this, because I don't understand the question. Far too confusingly posed to make sense. I think you are asking how to break the curve into exactly 8 parts, each as equal in length as possible. I can only assume you mean distance traveled along the curve, so arclength. Sadly, arclength is not terribly well defined on a noisy curve, but that is something only you can deal with. I'd assume just a piecewise linear arclength, so a connect-the-dots curve.
Next, you insist that one of those stars MUST appear in each segment. The starred points "seem" to be zero-crossings, but even that is not clear. Are the stars every zero crossing of this noisy curve? How did you choose those points? Can a starred point be shared across two segments? That is, if a starred point lies at the break point between two segments, is that sufficient?
Next, what is the point of this task? What is your goal?
I ask that question because far too often I see people ask a specific confusing question on Answers, when their real goal is something relatively simple to solve, IF they knew how to solve that problem. So, is your goal in this task to locate those roots/zero crossings?
If you really wanted to break the curve into segments that are all roughly as much as possible equal in length, such that each segment MUST include at least one of those starred points. Then...
Find the total arc length along the curve.
Break the curve into 8 segments, where each segment has the same arc length. I have posted a tool on the file exchange which can do exactly this. Test to see if each segment contains at least one starred point. If not, then adjust the segment lengths, perhaps using an optimization tool, until the goal is satisfied.
If your final goal is something different, so as I suggested, it is merely to find the zero crossings of that function, there are tools that can do this trivially in one call.
3 个评论
Image Analyst
2020-6-22
So is the minimum for a 1/8th segment of x one star or zero stars?
And I do not understand the grammar of this sentence: "Then I want to see if each splitted region/part got minimum 1 abrupt cutoff." It seems there are some crucial words missing in that sentence.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!