Reputation: 9806
I want to make a contour plot of three variables.
x coordinate , y coordinate and speed
Then I wish to depict the velocity directions on same plot with quiver.
Code:
k=49;
data_k=data(:,1)==k&sp>sp_ths;%filter data
x=xcor(data_k);y=ycor(data_k);sp_k=sp(data_k);vx_k=vx(data_k);vy_k=vy(data_k);
if contour_plot
[Xq, Yq] = meshgrid(x,y);
Zq =griddata(x,y,sp_k,Xq,Yq);
contour(Xq,Yq,Zq,5)%,'ShowText','on');
end
hold on
quiver(x, y, vx_k*5, vy_k*5, 0, 'k');
contour seems incorrect, I cant understand why though.
Data:
>> [x,y,vx_k,vy_k,sp_k]
ans =
57.3030 61.6410 0.8965 0.4430 2.0000
84.9540 -0.0559 0.9534 0.3017 2.0000
80.3200 7.7009 0.9009 0.4339 2.0000
76.6780 -35.6720 0.9391 -0.3437 2.0000
61.4120 54.7280 0.3449 0.9386 2.0000
70.9940 32.3250 0.7934 0.6088 2.0000
-77.8030 4.8428 -0.9998 -0.0178 2.0000
-39.4330 66.0040 -0.6452 0.7640 2.0000
-41.1680 -70.1010 -0.9055 -0.4244 2.0000
57.7840 -58.3810 0.9264 -0.3765 2.0000
-70.2350 -8.8322 -0.9975 0.0712 2.0000
-77.6940 -26.3810 -0.9676 -0.2525 2.0000
-49.7200 -48.1560 -0.5801 -0.8145 2.0000
-34.4620 -76.7420 -0.6990 -0.7151 2.0000
68.3490 21.6690 0.9678 -0.2516 2.0000
71.7360 -16.5990 0.9287 -0.3709 2.0000
17.9180 -66.0220 0.5107 -0.8598 2.0000
-57.2370 -55.8160 -0.9522 -0.3055 2.0000
86.0120 5.7037 0.9336 0.3583 2.0000
75.7290 16.6260 0.9946 0.1035 1.9114
-78.2140 4.6192 -0.9969 0.0783 2.0000
42.9320 -63.1170 0.5138 -0.8579 2.0000
-56.5820 39.2650 -0.2098 0.9777 2.0000
-18.2490 75.0340 -0.0854 0.9963 2.0000
75.4960 -28.2940 0.8437 -0.5367 2.0000
-17.6210 74.9380 -0.0340 0.9994 2.0000
-10.9350 -79.1950 -0.3356 -0.9420 2.0000
-16.2720 69.7160 0.2938 0.9559 2.0000
-70.9780 -37.1290 -0.9887 0.1496 2.0000
71.9370 -38.4470 0.8501 -0.5266 2.0000
73.3310 -7.0563 0.9994 0.0341 2.0000
83.7780 19.1370 0.8500 0.5268 2.0000
-8.1897 79.2620 0.0479 0.9989 2.0000
56.7250 62.4670 0.9049 0.4256 2.0000
56.6710 62.1070 0.8763 0.4818 2.0000
77.0110 9.7810 0.9787 -0.2053 2.0000
56.3630 62.7070 0.9476 0.3195 2.0000
84.0260 0.2988 0.9618 0.2737 2.0000
-68.5600 -42.1320 -0.9822 -0.1880 2.0000
55.5620 63.5370 0.6724 0.7402 2.0000
19.3120 -67.2460 0.1840 -0.9829 2.0000
-71.6530 28.4280 -0.9346 0.3558 2.0000
-35.6610 -75.9520 -0.1767 -0.9843 2.0000
33.1410 -75.3810 -0.1116 -0.9938 2.0000
55.1580 56.8510 0.5865 0.8099 2.0000
34.6410 -75.9710 0.3960 -0.9183 2.0000
57.9810 -58.1830 0.8255 -0.5645 2.0000
62.0610 -56.7770 0.8238 -0.5669 2.0000
46.5930 -68.1200 0.9947 -0.1029 2.0000
38.4250 -74.4980 0.3652 -0.9309 2.0000
-46.0560 -67.3300 -0.3544 -0.9351 2.0000
75.8290 18.4470 0.9997 0.0244 1.9114
72.4200 31.8080 0.9841 0.1777 2.0000
61.8330 -53.1870 0.9163 -0.4005 2.0000
-62.1240 -25.1080 -0.6117 -0.7911 2.0000
57.0410 62.0730 0.8391 0.5440 2.0000
73.0400 -2.7887 0.9313 0.3643 2.0000
39.0000 -73.7550 0.3970 -0.9178 2.0000
81.8430 -20.8660 0.9697 -0.2443 2.0000
-77.8410 4.7747 -0.9584 0.2853 2.0000
Upvotes: 0
Views: 1092
Reputation: 2331
I hope I have the answer for you here: Drawing 3D contour from 3D data
For start, contour
and contour3
plots are to represent scalar fields, not vector fields. For vector field You can use quiver
and quiver3
plots.
Note that for Contours You need two M-vectors of x
and y
coordinates and one M-matrix of z
data, where z(ii,jj)
corresponds to x(ii)
and y(jj)
, but for quiver you need M-vectors of coordinates and M-vectors of vector directions, where x(ii)
, y(ii)
, z(ii)
, u(ii)
, v(ii)
and w(ii)
represent one "arrow" in the plot.
It would me helpful to provide image how it should look like.
Upvotes: 1