Set-up animation time in paraview from one column - time

I have a .txt file containing columns of data. At each row, i have 5 columns, containing object id, time, x position, y position, z position.
Example:
ID Time X Y Z
0 0 0 0 0
1 0 1 0 0
3 0 0 1 0
0 1 0 0 0
1 1 0 1 0
I don't know how to set up Paraview to read the column Time as the Time in the animation.
I know it's possible with multiple files (one for each time step), but is it possible with one single file containing all the time steps as shown above ?
Thanks for advice

Not supported in ParaView (last release 5.6.0) by default, but it should be quite easy to do it with a live programmable source.

Related

Fill matrix randomly without row-repetitions

Please help. I'm new to matlab scripting and need a bit of help. I have a series of numbers:
A=[1 1 1 2 2 2 3 3 3 4 4 4 5]
which I want to fill randomly into an 8x12 matrix without having the same number in the same row. At the end I want all the "empty" cells of the 8x12 matrix being filled with 0's or nan.
an example could be:
result=
3 1 5 2 4 5 0 0 0 0 0 0
4 1 3 2 0 0 0 0 0 0 0 0
1 3 4 2 0 0 0 0 0 0 0 0
make sure A is sorted. A = sort(A)more info
make an empty matrix.
For each number in A: more info
find out how many repetitions of the number there are -> for loop in A, start is the first occurance of the number, end is the last, n = last-first+1
find all rows that have space for an extra number, just do a double for loop and keep track of elements that are zero
randomly pick n rows -> more info. To do this, make an array R of all available row indixes. Then take a random sample between 1..size(R,2) with the provided function and get all the values, you now have your row indixes.
randomly pick one of the empty spots in each of the selected rows and assign the number

Connected component labeling in matrix

I'm trying to do the following
Given the following matrix (where 1's are empty cells and 0's are obstacles):
0 0 1 1
1 0 0 0
1 0 1 1
1 1 0 0
I want it to become like this:
0 0 1 1
2 0 0 0
2 0 2 2
2 2 0 0
What I need to do is to label all connected components (free spaces).
What I already tried to do is to write a function called isConnected() which takes indexes of two cells and checks if there is a connected path between them. And by repeating this function n^2 times on every empty cell on the matrix I can label all connected spaces. But as this algorithm has a bad time complexity (n^2*n^2*O(isConnected())) I prefer to use something else.
I hope these pictures will explain better what I'm trying to accomplish:

create multiple NxM matrices

I'm looking for a code which returns all combinations of NxM matrices consisting of only ones and zeros. Every row contains precisely one '1'. Every column consists of one or more '1'. If the rules for rows and columns are hard to program they may be left out since computational problem is not going to be an issue.
1 0 0
1 0 0
1 0 0
0 1 0
0 0 1
1 0 0
1 0 0
0 1 0
0 1 0
0 0 1
etc. etc. etc.
Hopefully someone can help me out.
Cheers, Raymond

Form a Matrix From a Large Text File Quickly

Hi I am struggling with reading data from a file quickly enough. ( Currently left for 4hrs, then crashed) must be a simpler way.
The text file looks similar like this:
From To
1 5
3 2
2 1
4 3
From this I want to form a matrix so that there is a 1 in the according [m,n]
The current code is:
function [z] = reed (A)
[m,n]=size(A);
i=1;
while (i <= n)
z(A(1,i),A(2,i))=1;
i=i+1;
end
Which output the following matrix, z:
z =
0 0 0 0 1
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
My actual file has 280,000,000 links to and from, this code is too slow for this size file. Does anybody know a much faster was to do this in matlab?
thanks
You can do something along the lines of the following:
>> A = zeros(4,5);
>> B = importdata('testcase.txt');
>> A(sub2ind(size(A),B.data(:,1),B.data(:,2))) = 1;
My test case, 'testcase.txt' contains your sample data:
From To
1 5
3 2
2 1
4 3
The result would be:
>> A
A =
0 0 0 0 1
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
EDIT - 1
After taking a look at your data, it seems that even if you modify this code appropriately, you may not have enough memory to execute it as the matrix A would become too large.
As such, you can use sparse matrices to achieve the same as given below:
>> B = importdata('web-Stanford.txt');
>> A = sparse(B.data(:,1),B.data(:,2),1,max(max(B.data)),max(max(B.data)));
This would be the approach I'd recommend as your A matrix will have a size of [281903,281903] which would usually be too large to handle due to memory constraints. A sparse matrix on the other hand, maintains only those matrix entries which are non-zero, thus saving on a lot of space. In most cases, you can use sparse matrices more-or-less as you use normal matrices.
More information about the sparse command is given here.
EDIT - 2
I'm not sure why it isn't working for you. Here's a screenshot of how I did it in case that helps:
EDIT - 3
It seems that you're getting a double matrix in B while I'm getting a struct. I'm not sure why this is happening; I can only speculate that you deleted the header lines from the input file before you used importdata.
Basically it's just that my B.data is the same as your B. As such, you should be able to use the following instead:
>> A = sparse(B(:,1),B(:,2),1,max(max(B)),max(max(B)));

Plotting multiple matrices gnuplot

I'm fairly new to gnuplot and I'm trying to see how my array varies with iterations of my program to debug, I would ideally like to be able to make an animation of the data.
Here's what my data looks like:
'q=0'
1 0 0
0 1 1
1 1 0
'q=1'
1 0 0
0 1 1
0 1 0
and so on.
I tried using: plot "matrix.dat" index 0 matrix with image, just to plot the first matrix but I got "Warning matrix contains missing or undefined values, Matrix does not represent a grid".
I think the problem may be the comment lines. When I used this version of your data file
1 0 0
0 1 1
1 1 0
1 0 0
0 1 1
0 1 0
plotting with index works. To make an animation, you could create a series of .png files and stitch them together with another application. An example of the gnuplot code to make the .pngs would be:
set terminal png
do for [i=0:100] {
set output sprintf('matrix%03.0f.png',i)
plot 'data.dat' index i matrix with image
}

Resources