MATLAB Answers

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

49 views (last 30 days)
Raghu Vamsi
Raghu Vamsi on 3 Feb 2020
Answered: Spencer Chen on 3 Feb 2020
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
x1 = csvread('Data1_Nm.csv');
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)

  0 Comments

Sign in to comment.

Answers (1)

Spencer Chen
Spencer Chen on 3 Feb 2020
You are on the right track. Let's start with:
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

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!