Reshaping the velocity data to match with generated meshgrid of x and y to further plot contour of velocity?
5 次查看(过去 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!