Info
This question is closed. Reopen it to edit or answer.
how to find data?
    6 views (last 30 days)
  
       Show older comments
    
Hi
please have a look on attached file
I can see the value 2.9377e+03 at index 5414
but the following code does not return anything
please tell me what is wrong, I need to extract all the Ys where Z is 29377
  aspdepth=Y(Z==29377);
            [aspdepth_sorted,aspdepth_order]=sort(aspdepth);
and I will be grateful and appreciate any fast help
Thank YOU
0 Comments
Answers (2)
  Raj
      
 on 3 Jul 2019
        
      Edited: Raj
      
 on 3 Jul 2019
  
      First of all 2.9377e+03=2937.7 and not 29377 as you are looking for. So relook into that.
Secondly, i think its just accuracy error. To check this run this:
load('Y.mat')
load('Z.mat')
Z(5414)
aspdepth=Y(Z==ans);
[aspdepth_sorted,aspdepth_order]=sort(aspdepth);
You need to change the data format to get correct result.
2 Comments
  Raj
      
 on 3 Jul 2019
				Hello,
1) Since you are looking for "equal or very close" you need to define a tolerance here. How much 'very close' is good enough for your case? Then instead of using '==' you can use a conditional statement something like this
load('Z.mat')
load('Y.mat')
survayline = 12*tand(60);
tolerance_value=10e-3; % Define your tolerance
jj=1;
for ii=1:length(Z)
    if abs(Z(ii)-survayline)<tolerance_value
     aspdepth(jj)=Y(ii);
     jj=jj+1;
    end
end
[aspdepth_sorted,aspdepth_order]=sort(aspdepth);
2) 
survayline = 12*tand(60)
gives output as survayline = 20.7846. This value is no where close to any values in the Z mat file that you have shared. If the Y and Z mat files that you had shared earlier are also example files, please use correct files or define a large tolerance.
This question is closed.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
