Info
此问题已关闭。 请重新打开它进行编辑或回答。
how to find data?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Raj
2019-7-3
编辑:Raj
2019-7-3
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 个评论
Raj
2019-7-3
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.
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!