Need to organize a large matrix into individual matrixes based on text files
1 view (last 30 days)
Show older comments
I am trying to write a code that will produce a contour plot of many PIV Data points from DaVis .txt files.
The .txt file has 4 columns of data (X coordinates, Y coordinates, U velocity, V velocity). As of now I have the code reading this file with dlmread skipping the first row. I now need to take all X values and put them into their own matrix, as well for the Y, and U values to plot with pcolor.
As you can see in the .txt file Y values remain constant for 124 trials. I am trying to start a new column for X values everytime the Y values change. This should work out to a matrix with 124 columns and 173 columns for each Matrix, since there are 124 X,U,V values for each value of Y, and Y changes values 173 times.
I was intially trying reshape however I believe I will need a loop function to do this now.
type B00001.txt;
A=dlmread('B00001.txt', '',1,0);
X = reshape(A(:,1),173,124);
Y = reshape(A(:,2),173,124);
U = reshape(A(:,3),173,124);
V = reshape(A(:,4),173,124);
pcolor(X,Y,U);
hold on
shading interp
colormap(jet);
colorbar
0 Comments
Accepted Answer
David Hill
on 21 Apr 2020
You should be fine, just reverse the order to (124,173). Elements are selected downward to fill the matrix. You can then transpose in you need 173x124 matrix.
X = reshape(A(:,1),124,173);
Y = reshape(A(:,2),124,173);
U = reshape(A(:,3),124,173);
V = reshape(A(:,4),124,173);
More Answers (0)
See Also
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!