How to find the Y Value in a Array and Locate corresponding X Value
조회 수: 12 (최근 30일)
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.
- I have an array of data 100x550. I need to find the 10% of 550 data and 90% of 550 data.
- Once this is captured i should be able to locate them in the 100x550 array of data
- Later i should be able to capture the relevant x1 & x2 values
- 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);
x4 = (90/100)*x2;
for i = 1:1:length(x1)
Hope to get some help, any more details needed please let me know.
(Mechanical Engineer - Trying to Learn Matlab and Simulink)
Spencer Chen 2020년 2월 3일
You are on the right track. Let's start with:
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().