missing glyphs when displaying vector field in paraview? - paraview

When visualizing the file below (paraview 4.2.0 64 bit linux), not all glyphs are rendered. For instance, the glyph at [7,0,0] (corresponding to pointID 7) is missing.
Can anyone confirm that behaviour?
file.vti
<?xml version="1.0"?>
<VTKFile type="ImageData" version="0.1" byte_order="LittleEndian" compressor="vtkZLibDataCompressor">
<ImageData WholeExtent="0 7 0 15 0 0" Origin="0 0 0" Spacing="1 1 1">
<Piece Extent="0 7 0 15 0 0">
<PointData>
<DataArray type="Float64" Name="thedata" NumberOfComponents="3" format="ascii" RangeMin="1.7320508076" RangeMax="221.70250337">
1 -1 1 2 -2 2
3 -3 3 4 -4 4
5 -5 5 6 -6 6
7 -7 7 8 -8 8
9 -9 9 10 -10 10
11 -11 11 12 -12 12
13 -13 13 14 -14 14
15 -15 15 16 -16 16
17 -17 17 18 -18 18
19 -19 19 20 -20 20
21 -21 21 22 -22 22
23 -23 23 24 -24 24
25 -25 25 26 -26 26
27 -27 27 28 -28 28
29 -29 29 30 -30 30
31 -31 31 32 -32 32
33 -33 33 34 -34 34
35 -35 35 36 -36 36
37 -37 37 38 -38 38
39 -39 39 40 -40 40
41 -41 41 42 -42 42
43 -43 43 44 -44 44
45 -45 45 46 -46 46
47 -47 47 48 -48 48
49 -49 49 50 -50 50
51 -51 51 52 -52 52
53 -53 53 54 -54 54
55 -55 55 56 -56 56
57 -57 57 58 -58 58
59 -59 59 60 -60 60
61 -61 61 62 -62 62
63 -63 63 64 -64 64
65 -65 65 66 -66 66
67 -67 67 68 -68 68
69 -69 69 70 -70 70
71 -71 71 72 -72 72
73 -73 73 74 -74 74
75 -75 75 76 -76 76
77 -77 77 78 -78 78
79 -79 79 80 -80 80
81 -81 81 82 -82 82
83 -83 83 84 -84 84
85 -85 85 86 -86 86
87 -87 87 88 -88 88
89 -89 89 90 -90 90
91 -91 91 92 -92 92
93 -93 93 94 -94 94
95 -95 95 96 -96 96
97 -97 97 98 -98 98
99 -99 99 100 -100 100
101 -101 101 102 -102 102
103 -103 103 104 -104 104
105 -105 105 106 -106 106
107 -107 107 108 -108 108
109 -109 109 110 -110 110
111 -111 111 112 -112 112
113 -113 113 114 -114 114
115 -115 115 116 -116 116
117 -117 117 118 -118 118
119 -119 119 120 -120 120
121 -121 121 122 -122 122
123 -123 123 124 -124 124
125 -125 125 126 -126 126
127 -127 127 128 -128 128
</DataArray>
</PointData>
<CellData>
</CellData>
</Piece>
</ImageData>
</VTKFile>

Try changing the Glyph Mode to All Points. In 4.2, the default is to use a sampling mechanism to attempt to get uniformly distributed glyphs.

Related

How to sum columns of a matrix for a specified number of columns?

I have a matrix A of size 2500 x 500. I want to sum each 10 columns and get the result as a matrix B of size 2500 x 50. That is, the first column of B is the sum of the first 10 columns of A, the second column of B is the sum of second 10 columns of A, and so on.
How can I do that without a for loop? Since I have to do that hundreds of times and it is highly time consuming to do that using for loop.
First, we "block reshape" A, such that we have the desired number of columns. Therefore, we shamelessly steal the code from the great Divakar, and put in some minimal effort to generalize it. Then, we just need to sum along the second axis, and reshape to the original form.
Here's an example with five columns to be summed:
% Sample input data
A = reshape(1:100, 10, 10).'
[r, c] = size(A);
% Number of columns to be summed
n_cols = 5;
% Block reshape to n_cols, see https://stackoverflow.com/a/40508999/11089932
B = reshape(permute(reshape(A, r, n_cols, []), [1, 3, 2]), [], n_cols);
% Sum along second axis
B = sum(B, 2);
% Reshape to original form
B = reshape(B, r, c / n_cols)
That's the output:
A =
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 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90
91 92 93 94 95 96 97 98 99 100
B =
15 40
65 90
115 140
165 190
215 240
265 290
315 340
365 390
415 440
465 490
Hope that helps!
This can be done with splitapply. An advantage of this approach is that it works even if the group size does not divide the number of columns (the last group is smaller):
A = reshape(1:120, 12, 10).'; % example 10×12 data (borrowed from HansHirse)
n_cols = 5; % number of columns to sum over
result = splitapply(#(x)sum(x,2), A, ceil((1:size(A,2))/n_cols));
In this example,
A =
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 26 27 28 29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70 71 72
73 74 75 76 77 78 79 80 81 82 83 84
85 86 87 88 89 90 91 92 93 94 95 96
97 98 99 100 101 102 103 104 105 106 107 108
109 110 111 112 113 114 115 116 117 118 119 120
result =
15 40 23
75 100 47
135 160 71
195 220 95
255 280 119
315 340 143
375 400 167
435 460 191
495 520 215
555 580 239

range of number to subset slices

I would like to reshape a vector into a number 'slices' (in Matlab) but find myself in a brain freeze and can't come up with a good way (e.g. a one-liner) to do it:
a=1:119;
slices=[47 24 1 47];
result={1:47,48:71,...};
the result doesn't need to be stored in a cell array.
Thanks
This is what mat2cell does:
>> a=1:119;
>> slices=[47 24 1 47];
>> result = mat2cell(a, 1, slices) % 1 is # of rows in result
result =
{
[1,1] =
Columns 1 through 15:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Columns 16 through 30:
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Columns 31 through 45:
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
Columns 46 and 47:
46 47
[1,2] =
Columns 1 through 15:
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
Columns 16 through 24:
63 64 65 66 67 68 69 70 71
[1,3] = 72
[1,4] =
Columns 1 through 13:
73 74 75 76 77 78 79 80 81 82 83 84 85
Columns 14 through 26:
86 87 88 89 90 91 92 93 94 95 96 97 98
Columns 27 through 39:
99 100 101 102 103 104 105 106 107 108 109 110 111
Columns 40 through 47:
112 113 114 115 116 117 118 119
}

MRT function [1] "error code = 0"

When I make my MRT, I got two errors:
[1] "error code = 0" and Error in indval.default(Ynode, clustering =
clustnode, numitr = 1000) : All species must occur in at least one
plot. Does anyone have an idea of why? I checked and all my species
have an abundance >0...
MRTtest=mvpart(vegetation~ Placette+ Tourb + Transect + Largcanal + Annouvert + Elevation + Profnappe + Litiere+ Solnu+ Deblign+ Densiometre+ EpaissMO+ Vonpostvingt+ Vonpostsoixante+ Pyrovingt+ Pyrosoixante+ Sommesurfterr,tot,margin=0.08,cp=0,xv="pick",xval=10,xvmult=150,which=4,pca=F)
X-Val rep : 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 26 27 28 29 30 31 32 33 34 35
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
106 107 108 109 110 111 112 113 114 115 116 117 118 119
120 121 122 123 124 125 126 127 128 129 130 131 132 133
134 135 136 137 138 139 140 141 142 143 144 145 146 147
148 149 150
Minimum tree sizes
tabmins
2 3 4 6
2 125 5 18
MRTtest1=MRT(MRTtest,percent=10,species=colnames(vegetation))
summary(MRTtest1)
Portion (%) of deviance explained by species for every particular node
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- Node 1 ---
Complexity(R2) 14.87422
Sommesurfterr>=6.024 Sommesurfterr< 6.024
~ Discriminant species :
THOnmtot THOmtot
% of expl. deviance 17.61057298 38.419650816
Mean on the left 0.37621604 0.430818462
Mean on the right 0.08877576 0.006259911
[1] "error code = 0"
~ INDVAL species for this node: : left is 1, right is 2
cluster indicator_value probability
THOmtot 1 0.9597 0.001
THOnmtot 1 0.7878 0.001
LEG 1 0.5802 0.031
LIB 1 0.5078 0.010
MELnmtot 1 0.4710 0.047
EPNnmtot 1 0.4404 0.026
Sum of probabilities = 87.497
Sum of Indicator Values = 30.02
Sum of Significant Indicator Values = 12.67
Number of Significant Indicators = 29
Significant Indicator Distribution
1 2
8 21
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- Node 2 ---
Complexity(R2) 7.920283
Densiometre< 19.88 Densiometre>=19.88
~ Discriminant species :
TRA THOmtot
% of expl. deviance 10.54536819 27.8848051
Mean on the left 0.02754503 0.5158733
Mean on the right 0.20823621 0.2220475
Error in indval.default(Ynode, clustering = clustnode, numitr = 1000)
: All species must occur in at least one plot

Comparing area between two matrices with multiple points of intersection (MATLAB)

I have two matrices that contain the points for the top boundaries of two jigsaw puzzles. I am trying to calculate the area contained between these two matrices (of unequal rows). They have multiple points of intersection. The picture below gives a better idea of what I'm trying to accomplish. The output should be a numerical value (of the total area highlighted in blue). If this is too difficult to achieve, is there a better way to compare matrices to see which ones "fit" the best?
Un-Highlighted Picture
Area(in blue) that I am trying to calculate (numerical value)
The matrix values are below if it helps:
Matrix 1:
1 1
2 2
3 2
4 2
5 2
6 3
7 3
8 3
9 3
10 3
11 3
12 2
13 2
14 2
15 2
16 2
17 2
18 2
19 2
20 2
21 2
22 2
23 2
24 2
25 2
26 2
27 2
28 2
29 2
30 2
31 2
32 2
33 2
34 2
35 2
36 2
37 2
38 2
39 2
40 2
41 2
42 2
43 2
44 2
45 2
46 2
47 2
48 2
49 2
50 2
51 2
52 2
53 2
54 2
55 2
56 2
57 2
58 2
59 2
60 2
61 2
62 2
63 2
64 2
65 2
66 2
67 2
68 2
69 2
70 2
71 2
72 3
73 3
74 3
75 4
76 5
77 6
78 7
79 8
79 9
80 10
80 11
80 12
80 13
80 14
80 15
79 16
79 17
79 18
78 19
78 20
78 21
77 22
77 23
77 24
76 25
76 26
76 27
75 28
75 29
75 30
74 31
74 32
74 33
73 34
73 35
73 36
73 37
73 38
72 39
72 40
72 41
72 42
72 43
72 44
73 45
73 46
73 47
74 48
75 49
76 50
77 51
78 52
79 53
80 53
81 54
82 54
83 55
84 55
85 56
86 56
87 57
88 57
89 57
90 58
91 58
92 58
93 58
94 59
95 59
96 59
97 59
98 59
99 59
100 59
101 59
102 59
103 59
104 59
105 59
106 59
107 59
108 59
109 59
110 59
111 59
112 58
113 58
114 58
115 58
116 57
117 57
118 57
119 56
120 56
121 56
122 55
123 55
124 54
125 53
126 53
127 52
128 51
129 51
130 50
131 49
132 48
132 47
133 46
133 45
133 44
133 43
133 42
133 41
133 40
133 39
133 38
132 37
132 36
132 35
131 34
131 33
131 32
131 31
130 30
130 29
130 28
130 27
129 26
129 25
128 24
128 23
127 22
127 21
127 20
127 19
126 18
126 17
126 16
126 15
126 14
126 13
126 12
126 11
126 10
126 9
127 8
128 7
129 6
130 5
131 4
132 3
133 3
134 2
135 2
136 2
137 2
138 2
139 2
140 2
141 2
142 2
143 2
144 2
145 2
146 2
147 2
148 2
149 2
150 2
151 2
152 2
153 2
154 2
155 2
156 2
157 2
158 2
159 2
160 2
161 2
162 2
163 2
164 2
165 2
166 2
167 2
168 1
169 1
170 1
171 1
172 1
Matrix 2:
173 3
172 3
171 3
170 2
169 2
168 2
167 2
166 2
165 2
164 2
163 2
162 2
161 2
160 2
159 2
158 2
157 2
156 2
155 2
154 2
153 2
152 2
151 2
150 2
149 2
148 2
147 2
146 2
145 2
144 2
143 2
142 2
141 2
140 2
139 2
138 2
137 2
136 2
135 3
134 3
133 3
132 3
131 4
130 4
129 4
128 5
127 6
127 7
127 8
126 9
127 10
127 11
127 12
127 13
127 14
126 15
127 16
127 17
127 18
127 19
127 20
127 21
128 22
128 23
128 24
128 25
129 26
129 27
129 28
130 29
130 30
130 31
131 32
131 33
131 34
132 35
132 36
132 37
132 38
133 39
133 40
133 41
133 42
133 43
132 44
132 45
132 46
131 47
130 48
129 49
128 50
127 51
126 52
125 53
124 54
123 54
122 55
121 55
120 55
119 56
118 56
117 57
116 58
115 58
114 59
113 59
112 59
111 59
110 60
109 60
108 60
107 60
106 60
105 60
104 60
103 60
102 60
101 60
100 60
99 60
98 60
97 60
96 60
95 59
94 59
93 59
92 59
91 59
90 58
89 58
88 57
87 57
86 56
85 56
84 55
83 55
82 54
81 54
80 53
79 52
78 51
77 50
76 49
75 48
74 47
73 46
73 45
73 44
73 43
73 42
73 41
73 40
73 39
73 38
73 37
73 36
74 35
74 34
74 33
75 32
75 31
75 30
76 29
76 28
76 27
77 26
77 25
77 24
78 23
78 22
78 21
79 20
79 19
80 18
80 17
80 16
81 15
81 14
81 13
81 12
81 11
81 10
80 10
79 9
79 8
78 7
77 6
76 5
75 4
74 4
73 3
72 3
71 2
70 2
69 2
68 1
67 2
66 2
65 2
64 2
63 2
62 2
61 2
60 2
59 2
58 2
57 2
56 2
55 2
54 2
53 2
52 2
51 2
50 2
49 2
48 2
47 2
46 2
45 2
44 2
43 2
42 2
41 2
40 2
39 2
38 2
37 2
36 2
35 2
34 2
33 2
32 2
31 2
30 2
29 2
28 2
27 2
26 2
25 2
24 2
23 2
22 2
21 2
20 2
19 2
18 2
17 2
16 2
15 2
14 2
13 2
12 2
11 2
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 3
Mark everything above one curve and mark everything below the other curve. Then you can get the area between the curves by finding where there are two marks.
You should take a look at this question Similarity measures between curves?

How can I display a large matrix without the word "Columns" appearing?

I want to display a large matrix, but I don't like the words "Columns x to y" to show. How can I do this?
You can use the function NUM2STR to format a large 2-D matrix A into a character array and display that. For example:
>> A = magic(15); %# This would likely break up columns when displayed
>> num2str(A) %# This won't
ans =
122 139 156 173 190 207 224 1 18 35 52 69 86 103 120
138 155 172 189 206 223 15 17 34 51 68 85 102 119 121
154 171 188 205 222 14 16 33 50 67 84 101 118 135 137
170 187 204 221 13 30 32 49 66 83 100 117 134 136 153
186 203 220 12 29 31 48 65 82 99 116 133 150 152 169
202 219 11 28 45 47 64 81 98 115 132 149 151 168 185
218 10 27 44 46 63 80 97 114 131 148 165 167 184 201
9 26 43 60 62 79 96 113 130 147 164 166 183 200 217
25 42 59 61 78 95 112 129 146 163 180 182 199 216 8
41 58 75 77 94 111 128 145 162 179 181 198 215 7 24
57 74 76 93 110 127 144 161 178 195 197 214 6 23 40
73 90 92 109 126 143 160 177 194 196 213 5 22 39 56
89 91 108 125 142 159 176 193 210 212 4 21 38 55 72
105 107 124 141 158 175 192 209 211 3 20 37 54 71 88
106 123 140 157 174 191 208 225 2 19 36 53 70 87 104