Reorganizing a large matrix into 4 other matrixes

조회 수: 2 (최근 30일)
rwn
rwn 2020년 4월 21일
댓글: rwn 2020년 4월 21일
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 need the program to reorganize the X column into its own matrix of 173x124, and the other columns to do the same for their own matrixes of the same size. I have the X,Y,U,V matrixes set to empty matrixes that need to be filled.
type B00001.txt;
A=dlmread('B00001.txt', '',1,0);
X=zeros(173,124);
Y=zeros(173,124);
U=zeros(173,124);
V=zeros(173,124);
pcolor(X,Y,U);
hold on
shading interp
colormap(jet);
colorbar
  댓글 수: 1
Sriram Tadavarty
Sriram Tadavarty 2020년 4월 21일
편집: Sriram Tadavarty 2020년 4월 21일
Ryan, can you place the B00001.txt file with the paperclip icon here?
What is the dimension of X column? Is that of value exactly equal to 173 x 124.
If yes, you can use reshape function. Like,
X = reshape(data(:,1),173,124);
Y = reshape(data(:,2),173,124);
U = reshape(data(:,3),173,124);
V = reshape(data(:,4),173,124);
Hope this helps.

댓글을 달려면 로그인하십시오.

채택된 답변

Sriram Tadavarty
Sriram Tadavarty 2020년 4월 21일
Hi Ryan,
Thanks for attaching the code.
The data is present in a matrix form with four columns covering X, Y, U, and V. You can just use the code that is placed in the comments and it will work.
Placing here again:
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
Hope this helps.
Regards,
Sriram

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by