How can I ort elements of a column in a matrix using elements of another column in another matrix
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
I have a matrix of 3 columns: A, B and C. The values of A and B are collected from floats. Each float collects data over a specific depth range by sinking several times. Thus, each sink produces a seperate depth profile. These profiles are assigned with numbers which are given in column C (if each float generates 10 profiles, then for the first float, C = 1 to 10; for the second float, C = 11 - 20 and so on...). For every C, there is a set of values for A and B. Hence my data look like:
Matrix 1
A      B      C
24	35     1
17	35     1
11	35     1
5	35     2
26	34     2
20	34     2
15    34     3     so on... 
A and B correlate with one another. Therefore I wanted to find y-intercepts of the A-B regression line for each profile. If we take the above dataset, for the three profiles shown, there will be three y-intercepts. Thus, my results look like: 
Matrix 2
Profile    Y-intercept
1                xxx
2               - xxx
3                xxx
IMPORTANT: The length of Matrix 2 is shorter than length of Matrix 1
The calculated y-intercepts can be either positive or negative. I am only interested in the positive values. I have already isolated the positive y-intercepts and the profiles that are responsible in generating them using an if loop. The next step I want to achieve is to go to the Matrix 1 and only keep rows where the value of C equals to the selected profile numbers. So I want to see something like this: 
Matrix 3
A      B      C
24	35     1
17	35     1
11	35     1
15    34     3     (because profile number 2 gives a negative y-intercept, I want all the rows corresponding to C = 2 eliminated). 
I can manually create Matrix 3 on an Excel by hand picking the rows based on the profiles. But I have data from 6098 profiles with a total of 29943 rows. Therefore I would very much like to know if there is any easier way of doing this on Matlab. 
Thank you in advance. 
댓글 수: 0
채택된 답변
추가 답변 (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!

