Reshaping the velocity data to match with generated meshgrid of x and y to further plot contour of velocity?
5 views (last 30 days)
Show older comments
Muhammad Atif on 17 Aug 2021
Commented: Muhammad Atif on 18 Aug 2021
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.
xmin=1; xmax=10; ymin=1; ymax=5;
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.
Cris LaPierre on 18 Aug 2021
Edited: Cris LaPierre on 18 Aug 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.
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!