Info
This question is closed. Reopen it to edit or answer.
When matlab coordinate is disagreed with file coordinate generated from external software
1 view (last 30 days)
Show older comments
I use Matlab to visualize the data in 3D. The data is generated by external software. I think I followed well the syntex upon slice function for 3D graphics. However, when slice function applies, the results is not right to the read file. I mean that Matlab coordinate shows x, y, z in clockwise. But when Matlab read the file, the 3D graphic data showed y,x,z in clockwise. Have you ever had similiar experience with me? Or Am I doing something wrong? I check my code many times but I can not see anything wrong. If you know a solution for this case, would you let me know please?
0 Comments
Answers (1)
Walter Roberson
on 8 Mar 2011
How are you doing the reading?
Remember that Matlab arrays are stored down columns not across rows, so if you fill sequential memory locations with values that you read from rows, you are going to be writing down columns.
For example, for a 3 x 2 array, A(1,1) is in memory next to A(2,1) which is next to A(3,1) which is next to A(1,2) which is next to A(2,2) which is next to A(3,2).
1 4 2 5 3 6
which would correspond to reading in the file
1 2 3 4 5 6
4 Comments
Walter Roberson
on 9 Mar 2011
That form of reading is going to result in a vector of values, not a 3 dimension array such as would be needed to extract data in the loop you showed.
If you used reshape() on the data to get a 3 dimensional array, then you are going to have exactly the difficulty I noted above: that consecutive values Matlab reads in will be stored down columns.
To fix this issue, use
data = permute(file, [2 1 3]);
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!