Reshaping the velocity data to match with generated meshgrid of x and y to further plot contour of velocity?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Cris LaPierre
el 18 de Ag. de 2021
Editada: Cris LaPierre
el 18 de Ag. de 2021
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.
Ver también
Categorías
Más información sobre Computational Fluid Dynamics (CFD) en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!