Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to find data?

1 回表示 (過去 30 日間)
Samaneh Arzpeima
Samaneh Arzpeima 2019 年 7 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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

回答 (2 件)

Raj
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 件のコメント
Samaneh Arzpeima
Samaneh Arzpeima 2019 年 7 月 3 日
Right,my question was not very accurate .I am sorry for taking your time.
I meant to give just an example
What I am really looking for is, to find all the Z with the value which is equal or very close to
12*tand(60)
BTW I don't know how to do it,and have been looking manually by draging Z up and down to find the coincident value.
so this is what I want to do
survayline = 12*tand(60) or if this value is not in Z,pick the closet value aspdepth=Y(Z==survayline);
[aspdepth_sorted,aspdepth_order]=sort(aspdepth);
can you please help for the second time
Raj
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.

Samaneh Arzpeima
Samaneh Arzpeima 2019 年 7 月 3 日
Now I am confused. I need to have one number to put it instead of 29377,in the following code.the one that I sent at the begining.
aspdepth=Y(Z==29377);
[aspdepth_sorted,aspdepth_order]=sort(aspdepth);
it should be
survayline = (12*tand(60))*1000;
or the closest value.
I couldn't understand what will be the value from your code.
survayline = (12*tand(60))*1000; %I had to multiply by 1000
%tolerance_value=10e-3; % Define your tolerance
tolerance_value=500;
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);

製品

Community Treasure Hunt

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

Start Hunting!

Translated by