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

채택된 답변

David Hill
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 CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by