在Matlab的特定点创建颜色图和颜色权重 [英] Creating colormap at specific point and color weights at matlab

查看:380
本文介绍了在Matlab的特定点创建颜色图和颜色权重的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些数据,其中包括一些挠度和力值.像deltaX deltaY一样,在该点测得的力为Fx和Fy.我想在该点上创建一个颜色图,其中力的大小和2D点之间的颜色过渡.例如,如果point1是红色(高值,大挠度),而point2是蓝色(低值,小挠度),则我希望它们之间可以进行颜色转换.您对此有何建议?

数据在下面给出. 第一栏位置X 第二栏位置Y 第三列力X 第四列力Y

我需要根据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

解决方案

您可以使用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

您可以按照以下步骤删除网格并进行插值:

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

然后从上方查看它:

view(2)

i have some datas which are included some deflection and force values. Like deltaX deltaY and forces measured at that points as Fx and Fy. I want to create a colormap at that points with the magnitude of forces and color transition between points in 2D. For example if point1 is red(high value, big deflection) and point2 is blue(low value, small deflection) i want color transition between them. Do you have any suggestion for that?

Data are given below. First column positionX second column positionY third column forceX forth column forceY

I need to plot this map according to X and Y positions and force magnitudes.

***When i take the magnitude of vectors we have positionX positionY and only 1 force value.

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

解决方案

You can use meshgrid and surf or mesh command to plot it:

[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

You can remove the mesh and interpolate as follows:

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

Then view it from above:

view(2)

这篇关于在Matlab的特定点创建颜色图和颜色权重的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆