1) I need a code to determine the intersection points, I have tried '==' is not working, also I would like to know if it is possible to make the grid line look like a graph sheet i.e using Xtick and Ytick
이전 댓글 표시

댓글 수: 4
Ezekiel Omoniyi
2019년 6월 14일
dpb
2019년 6월 14일
Try
hAx=gca;
hAx.XMinorTick='on';
and see what effect and if adequate. The number of minor ticks is determined internally and not specifically settable, though, unfortunately.
You can, of course, physically set 'XTick' as desired to any locations you wish but there isn't sufficient room to label 10 more ticks between the two existing so you'd then have to also manually set the 'XTickLabel' property to explicitly label the desired ticks--by default all major ticks are labelled 1:1 with the assocated XTick value.
Ezekiel Omoniyi
2019년 6월 14일
dpb
2019년 6월 14일
Use interp1 to find intersection points and then just add those to the existing XTick value vector. You will have to sort that to write them out.
But, that's probably not what you really want is having another tick mark because the intersections appear to almost identically on the existing ticks at 0.38 and 0.46 -- unless you're talking y-axis, maybe??? But even there, it'll get pretty crowded on the axis to insert another tick there.
I'd say you'd be better off to just put a marker and text annotation at or near the points instead...
채택된 답변
추가 답변 (2개)
Method one: functions
>> F1 = @(x)1.5*x-1;
>> F2 = @(x)0.3*x;
>> X = 0:4;
>> plot(X,F1(X),X,F2(X))

Now find the intersection:
>> yi = fzero(@(x)F1(x)-F2(x),1)
yi = 0.83333
And checking:
>> F1(yi)
ans = 0.25000
>> F2(yi)
ans = 0.25000
Method two: interpolate numeric data
If you have data values rather than functions then you can interpolate the data and use fzero:
>> Y1 = F1(X)
Y1 =
-1.0000 0.5000 2.0000 3.5000 5.0000
>> Y2 = F2(X)
Y1 =
-1.0000 0.5000 2.0000 3.5000 5.0000
>> G1 = @(x)interp1(X,Y1,x);
>> G2 = @(x)interp1(X,Y2,x);
>> yi = fzero(@(x)G1(x)-G2(x),1)
yi = 0.83333
And checking:
G1(yi)
ans = 0.25000
G2(yi)
ans = 0.25000
카테고리
도움말 센터 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

