# How to find the Y Value in a Array and Locate corresponding X Value

조회 수: 16 (최근 30일)
Raghu Vamsi 2020년 2월 3일
답변: Spencer Chen 2020년 2월 3일
Hi,
I have series of questions regarding an array of data that i have and how to capture the value and plot and find relevant values in X axis. Below is the query.
1. I have an array of data 100x550. I need to find the 10% of 550 data and 90% of 550 data.
2. Once this is captured i should be able to locate them in the 100x550 array of data
3. Later i should be able to capture the relevant x1 & x2 values
4. Finally plot.
Below is the code upto which i was successful in capturing point 1, but stuck with 2, 3 & 4
x2 = x1(:,550);
x3 =(10/100)*x2;
x4 = (90/100)*x2;
X=0;
for i = 1:1:length(x1)
X=find(x1(i)~=x4(i));
end
Hope to get some help, any more details needed please let me know.
Thank you
Regards
Raghu
(Mechanical Engineer - Trying to Learn Matlab and Simulink)

댓글을 달려면 로그인하십시오.

### 답변 (1개)

Spencer Chen 2020년 2월 3일
X=find(x1(i)~=x4(i));
Indexing into x1 and x4 is your problem here. Think about the difference between how you index into a 2D matrix (x1) and a 1D vector (x4).
Once you work that out, then rethink how to do this for-loop properly:
for i = 1:1:length(x1) ...
Lastly, you need to think about yout "X". The way you have set it up, the value in X is overwritten every iteration of the for-loop. So you will only get the last value of X out from your loop. So you'll need to think about how you can get every calculated "X" out from your for-loop.
Finally, not sure of the exact problem that you were asked to solve. I suspect that you may be misreading it. I have a suspision that your original problem may related to the function quantile().
Blessings,
Spencer

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by