Interpolate line data to grid matlab
17 ビュー (過去 30 日間)
古いコメントを表示
How can I find the points (red circles) which an arbitrary line (blue line) intersects in a grid?
0 件のコメント
回答 (1 件)
Star Strider
2024 年 4 月 3 日 18:19
編集済み: Star Strider
2024 年 4 月 3 日 21:47
x = [0.0 5.0];
y = [1.0 3.8];
figure
plot(x, y)
grid
hold on
Ax = gca;
xtix = Ax.XTick % X-Tick Grid Line Locations
yvals = interp1(x, y, xtix) % Interpolate
scatter(xtix, yvals) % Plot Results
hold off
ylim([0 5])
Also, if you do not have the information that created the plot, you can get it from the plot —
GetLines = findobj(Ax, 'Type','Line');
xv = GetLines.XData
yv = GetLines.YData
yvals = interp1(xv, yv, xtix)
EDIT — (3 Apr 2024 at 21:47)
Added the last part with ‘GetLines’ and following code.
.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で 3-D Volumetric Image Processing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!