How to find the Y Value in a Array and Locate corresponding X Value
16 次查看(过去 30 天)
显示 更早的评论
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.
- 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);
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 个评论
回答(1 个)
Spencer Chen
2020-2-3
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!