Finding multiple x-axes points from y-axes value
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
How do I find the x-values from a curve where the y-intercept cuts at 2 points? Please see attached image. I need to find the x-axes values associated with the two dropped lines for a fixed y = 10e-6 (for example)
I have tried using functions like interp1 and yval but they do not seem to work. Thanks!
3 commentaires
dpb
le 4 Août 2016
OK, that's better...hmmm :( On a sample here I just learned interp1 no longer behaves the way I'm used to; what a bummer!
Looks like griddedInterpolant also doesn't work well in the inverse interpolating mode when there's reversals in magnitude; not too surprising.
I've got meetings to prepare for shortly so ran out of time right now, I'd look at fzero to find the crossing after bracketing the range I think...
Réponses (1)
dpb
le 4 Août 2016
Modifié(e) : dpb
le 4 Août 2016
OK, try this or a version thereof...
>> y=bsxfun(@plus,randn(10),linspace(0,10,10).'); % make some sample data grossly similar...
>> yCrs=6; % set crossing level of interest
>> del=[zeros(1,10); diff(sign(y-yCrs))==2]; % find point past yCrs
>> [r,c]=ind2sub(size(del),find(del)); r=r.'; % return row for each
>> for i=1:10
xCrs(i)=interp1(y(r(i)-1:r(i),i),r(i)-1:r(i),yCrs);
end % interpolate over range
>> xCrs=[min(xCrs) max(xCrs)] % range of crossings
xCrs =
5.6484 7.4861
Above gives--
>> plot(y)
>> line(xlim,[yCrs yCrs],'linestyle',':','color','k')
>> line([xCrs(1) xCrs(1)],ylim,'linestyle',':','color','k')
>> line([xCrs(2) xCrs(2)],ylim,'linestyle',':','color','k')
ADDENDUM Depending upon just how "jaggedy" the individual lines can be, may need to do the above bounding for both first and last crossing(s) if, besides there being a sign change in the slope the observation can cross the threshold and then go back below again. That'd essentially be find with the 'first' and again with 'last' option to set the range. Then you've got the issue that will have to interpolate both sections as well since the inverse interpolation will not work with the double-valued independent variable when you turn x, y on their heads as dependent, independent variables instead. My sample data had slope reservals, but didn't actually cross below the chosen threshold; admit I didn't think of it specifically then.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!