在matlab

时间:2017-02-28 16:44:31

标签: matlab plot

我有一些数据包括一些偏转和力值。像deltaX deltaY和在那些点测量的力为Fx和Fy。我想在这些点处创建一个色彩图,其中力的大小和2D中点之间的颜色过渡。例如,如果point1为红色(高值,大偏转),而point2为蓝色(低值,小偏转),我想要它们之间的颜色过渡。你有什么建议吗?

数据如下。 第一列位置X 第二列位置Y. 第三栏forceX 第四列forceY

我需要根据X和Y位置以及强度来绘制此地图。

***当我取向量的大小时,我们有positionX positionY且只有1个力值。

filein =

         0         0   -0.0395    0.1189
         0    1.5053    0.2127  -11.3568
   -0.0008    3.0082    0.6719  -22.0470
   -0.0048    4.5093    0.9231  -32.7004
    0.0069    6.0033    1.2499  -43.2750
   -0.0029    7.5008    1.6960  -53.4941
    1.4981    0.0102   -1.5213    1.2031
    1.4979    1.5003   -1.2326  -10.0738
    1.5071    3.0043   -0.6965  -20.7386
    1.4896    4.4943   -0.2563  -31.5026
    1.5020    5.9921    0.0480  -42.3186
    1.5021    7.4909    0.7614  -52.7354
    3.0016    0.0022   -2.6099    1.9455
    3.0022    1.4960   -2.6157   -9.3388
    2.9959    3.0087   -1.8898  -20.1823
    2.9955    4.4977   -1.3670  -30.7842
    2.9923    6.0041   -0.8444  -41.7370
    2.9976    7.5055   -0.2241  -52.1361
    4.4995   -0.0016   -4.0576    2.5489
    4.5009    1.4961   -3.8135   -8.6871
    4.4930    2.9939   -3.0315  -19.4825
    4.4986    4.5045   -2.6034  -30.2974
    4.5046    5.9931   -1.9570  -40.9145
    4.4972    7.5023   -1.1994  -51.4071
    5.9931   -0.0014   -5.1986    3.2395
    5.9954    1.5000   -5.1224   -7.9289
    6.0017    2.9977   -4.3153  -18.7471
    6.0045    4.4939   -3.6613  -29.4662
    6.0030    6.0081   -2.9086  -40.3400
    6.0003    7.5006   -2.1704  -50.6973
    7.4974   -0.0018   -6.5690    4.0048
    7.4977    1.5043   -6.5230   -7.0994
    7.5047    3.0058   -5.5833  -18.0435
    7.5083    4.5058   -4.8070  -28.6861
    7.5024    6.0059   -4.0150  -39.4321
    7.5006    7.5023   -3.1837  -49.8617

1 个答案:

答案 0 :(得分:0)

您可以使用meshgridsurfmesh命令绘制它:

[X,Y] = meshgrid(filein(:,1),filein(:,2));
M = sqrt(filein(:,3).^2+filein(:,4).^2);
Z=meshgrid(M,M);
C = gradient(Z);
figure
surf(X,Y,Z,C);colorbar

enter image description here

您可以删除网格并进行插值,如下所示:

surf(X, Y, Z,'EdgeColor', 'None', 'facecolor', 'interp');

enter image description here

然后从上面查看:

view(2)

enter image description here