When matlab coordinate is disagreed with file coordinate generated from external software
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
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?
Antworten (1)
Walter Roberson
am 8 Mär. 2011
0 Stimmen
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 Kommentare
Soyoung
am 8 Mär. 2011
Walter Roberson
am 8 Mär. 2011
Your loop is the same
data = file(1:length_x,1:length_y,1:length_z);
which is probably the same as
data = file;
I think you may have missed showing a step in the reading, as you do not show any calls that do file I/O. Are you using fscanf() or textscan() or textread() or importdata() or load() or xlsread() or dlmread() or ... ?
Soyoung
am 9 Mär. 2011
Walter Roberson
am 9 Mär. 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]);
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!