フィルターのクリア

fitting only continous line

4 ビュー (過去 30 日間)
salman abbasi
salman abbasi 2020 年 11 月 10 日
コメント済み: salman abbasi 2020 年 11 月 10 日
HI
I have a plot of coninouts lines(from top 1,3,6) and discontinous lines. I like to retrieve only the continous line. How can i achieve it using polyfit. Please note that slope of continous and discontinous line is same.
Please see attached image
thanks
  4 件のコメント
John D'Errico
John D'Errico 2020 年 11 月 10 日
Please don't ask the same question a third time. You've not gotten an answer to either question becuase it is not clear what you want. Vague questions tend not to get answers, or if they do get an answer, it will be slowly arriving, and probably not on-target.
You cannot use polyfit to fit a picture of a line. If you plotted the data, then pass the data for the line into polyfit. This is trivial. So your question seems not to be a problem of "fitting" a line, but of finding the data to fit.
You have said you want to fit only the continuous lines. But the fact is, any picture of a line as you have it is NOT continuous, but a discrete pixelated approximation to a line. And if you have plotted points, then again, it is a discrete set of points. So there is no such thing as a continuous line in any of what you have shown. If you can extract a specific set of points, then perhaps you may decide some measure that would disambiguate between points that are sufficiently close together to be effectively continuous. But that is a completely different question, totally unrelated to any question of fitting. This would become a pre-processing problem.
What you probably need to do is first, come up with a scheme that will extract the data you care about, and somehow decide which lines are ones you like and which are not. Only then does this become a problem about modeling. And it ertainly is not a question about MATLAB, not until you have some idea what you really need to do.
salman abbasi
salman abbasi 2020 年 11 月 10 日
@John. thant for the suggestion. I would be careful postinng same question more than once. I thought mayb by re defiining the problem, i could get the solution. Which i did. But no way i would like to disorganize the system. Thank you for your other suggestion. You are right, it was more of pre-processing problem and i learned from your response. Until next time. Have a good one!

サインインしてコメントする。

採用された回答

David Goodmanson
David Goodmanson 2020 年 11 月 10 日
編集済み: David Goodmanson 2020 年 11 月 10 日
Hi salman,
I have been off taking a look at this problem. The method below uses the fact that what you call the discontinouus lines have matrix entries close to zero in every other column. In the code below, small values are set to zero in the diagnostic matrix m, both so the spy option can be used and so the discontinuous lines can be removed. Figures 2 and 3 illustrate the difference. Figure 4 shows the indices where the first column of the diagnostic matrix is nonzero. That's where the blob representing the 'continuous' lines cross the axis in the original image plot. I will leave it to you to determine which index to use for each line. Note that the values in the diagnostic matrix m have nothing to do with m77. The matrix iis just used to find indices, and to use spy.
It's true that asking the same question more than once on the website is not a good approach. Better to amend the original answer to make it more clear what you are aking.
m = 1e6*m77; % rescale matrix for convenience
figure(1)
imagesc(m)
colorbar
% matrix has no exact zeros, so create some when m is small
tol = 1e-2;
m(abs(m)<tol)= 0;
figure(2)
spy(m)
axis square
% 'discontinuous' lines are zero in every other column, eliminate them
m = m(:,1:2:end).*m(:,2:2:end);
figure(3)
spy(m) % only the 'continuous' lines are left
axis square
firstcol = m(:,1);
figure(4)
plot(abs(firstcol))
  1 件のコメント
salman abbasi
salman abbasi 2020 年 11 月 10 日
@David. Thank you so much. It worked.Stuck to this problem for 3 days. This was my last step in producing result for my paper.Amazing.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by