Reshaping the velocity data to match with generated meshgrid of x and y to further plot contour of velocity?
4 ビュー (過去 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!