Reshaping the velocity data to match with generated meshgrid of x and y to further plot contour of velocity?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I have some CFD data on a plane. The data include x,y,z,u,v, and w information. I have read the data and further doing proper orthognal decomposition on this data but I know how to do that.
Here I have created a very simple matrix to understand what reshape and other functions does.
%Test code%
xmin=1; xmax=10; ymin=1; ymax=5;
x=linspace(xmin,xmax,10);
y=linspace(ymin,ymax,10);
[X,Y]=meshgrid(x,y);
U=10.1:0.1:11;
V=U';
U_reshaped= reshape(U(zeros(10^2,1), X(:), Y(:)), [10 10]);
This is the code I am trying on my large CFD data. However this last command "reshape" is not working. I ma getting following error below. I have copied this command from another example where it is working perfectly fine in the same format.
"Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in Untitled (line 22)
U_reshaped= reshape(U(zeros(10^2,1), X(:), Y(:)), [10 10]);"
I am very new to matlab. I would highly appriciate any help.
Thanks
댓글 수: 0
답변 (1개)
Cris LaPierre
2021년 8월 18일
편집: Cris LaPierre
2021년 8월 18일
Your error is referring to this command: U(zeros(10^2,1))
You have already defined U, so the zeros are being interpretted as indices. You cannot use 0 as an index. In MATLAB, indexing begins at 1.
참고 항목
카테고리
Help Center 및 File Exchange에서 Computational Fluid Dynamics (CFD)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!