Effacer les filtres
Effacer les filtres

Can you please explain these line of code?

2 vues (au cours des 30 derniers jours)
Mohammad Wajih
Mohammad Wajih le 3 Jan 2015
fid = fopen( geomFile );
xPos = zeros(1,geoSize);
for kk = 1:geoSize;
xPos(kk) = fread( fid, 1, '*uint32' );
end
fclose(fid);
max_xPos = max(xPos);
xdim = max_xPos - min_xPos +1;
Any kind of help is appreciated!!

Réponse acceptée

Geoff Hayes
Geoff Hayes le 3 Jan 2015
Mohammad - why not step through the code to see what is happening? A file is opened, three matrices are sized, then an x and y an z coordinate is read for each element in the three matrices. The file is closed, and the min and max (x,y,z) coordinate is found. For more information on each function type the following in the Command Window
doc fopen
doc fread
doc fclose
doc min
doc max
As for why the code is doing this, hopefully you have an idea on that! :)
  4 commentaires
Mohammad Wajih
Mohammad Wajih le 4 Jan 2015
Thank you Mr. Hayes for your answer. Actually, I don't know who the author of this code is. This code used to work for me but now I don't know why its not working. So, I am trying to understand each and every line. Thanks for your response. I really appreciate it.
Image Analyst
Image Analyst le 4 Jan 2015
I agree with Geoff: calling them dim is a horrible name for the variables since it's really the range of the data, not the dimensions. For example if the data range from 1000 to 1005, that does not mean that the dimension of an array to hold all that data should be 6 - there could be hundreds of pixels in that range. But you really have to define what "its not working" means to you for us to fix it.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Text Data Preparation dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by