필터 지우기
필터 지우기

How to divide a curve into 8 equal region along x axis?

조회 수: 3 (최근 30일)
joynob ahmed
joynob ahmed 2020년 6월 19일
댓글: joynob ahmed 2020년 7월 3일
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?
I have attached my code and the image.
  댓글 수: 2
KSSV
KSSV 2020년 6월 19일
How about using reshape?
joynob ahmed
joynob ahmed 2020년 6월 22일
But when I used reshape it didn't give me the distribution of star in that way

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
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
joynob ahmed
joynob ahmed 2020년 6월 26일
편집: joynob ahmed 2020년 7월 3일
But this code reshapes such that the first 8 point fall into 8 different region where as I wanted to divide so that 1st 497 points which means all the point in first region to be in the x=1.I have checked the result.If I do so the result won't be correct.
Is there any way to rearrange this?
joynob ahmed
joynob ahmed 2020년 7월 3일
It works when I changed the row and column of the matrix. Thank you for your answer.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

John D'Errico
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
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.
joynob ahmed
joynob ahmed 2020년 6월 22일
when a region got star,its value will be 1. Abrupt cut off indicates star here.

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by