Need to organize a large matrix into individual matrixes based on text files
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
David Hill
2020-4-21
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!