在2D MATLAB数组中的两点之间取一维切片

时间:2017-12-21 12:27:38

标签: arrays matlab

我试图编写一个在const router = new VueRouter({ ... }) router.beforeEach = (to, from, next) => { // ... }) 数组中给出2个点的函数将返回连接这些点的(New-Object System.Net.Sockets.TcpClient -ArgumentList DESTINATION-IP,PORT).Connected 元素。

所以2D MATLAB

并且1D arrayarr=[1 2 3 4 5;6 7 8 9 10;11 12 13 14 15;16 17 18 19 20;21 22 23 24 25 ]之间的点将返回为arr(4,2)]。

例如,虽然如果需要,我可以插补点。

如果它有助于我在Python中这样做

arr(1,5)

1 个答案:

答案 0 :(得分:3)

您可以使用interp2

假设我们要从(1.3, 2.4)(4.6, 3.5)

采样20个均匀空格点
arr=[ 1  2  3  4  5;
      6  7  8  9 10;
     11 12 13 14 15;
     16 17 18 19 20;
     21 22 23 24 25 ]

[x, y] = meshgrid(1:5,1:5)
xx = linspace (1.3, 4.6, 20)
yy = linspace (2.4, 3.5, 20)
interp2(x,y,arr, xx,yy)

给出:

 8.30000000000000
 8.76315789473684
 9.22631578947368
 9.68947368421053
10.15263157894737
10.61578947368421
11.07894736842105
11.54210526315790
12.00526315789474
12.46842105263158
12.93157894736842
13.39473684210526
13.85789473684211
14.32105263157895
14.78421052631579
15.24736842105263
15.71052631578947
16.17368421052632
16.63684210526316
17.10000000000000

您可以看到线条如何跟随网格:

mesh(x,y,arr)
hold on
plot3(xx,yy,interp2(x,y,arr, xx,yy))

enter image description here

相关问题