fitting only continous line
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
salman abbasi
el 10 de Nov. de 2020
Comentada: salman abbasi
el 10 de Nov. de 2020
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 comentarios
John D'Errico
el 10 de Nov. de 2020
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.
Respuesta aceptada
David Goodmanson
el 10 de Nov. de 2020
Editada: David Goodmanson
el 10 de Nov. de 2020
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))
Más respuestas (0)
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!