Prev: assign a name to variables loaded with "load" or find out the name
Next: Fitting data and then accessing sse, rsquare, dfe, adjrsquareand rmse values
From: james on 28 Jun 2010 12:38 I have a set of three arrays as follows: A= B= Grades= 1 5 85 2 7 70 3 2 80 4 12 91 5 4 92 6 2 68 7 1 73 8 11 82 9 10 79 I want to take these three arrays and form two arrays from them. One of the arrays will take the A values and the grade by looking at column B. If column B has a number less than 10 than take that A value in that row and its grade value next to it. my two arrays when I am done would look like this: A1= 1 85 2 70 3 80 5 92 6 68 7 73 B1 would just have the grades and A values that correspond to if the B array had a number greater than or equal to 10. B1 would = 4 91 8 82 9 79 Ive been stuck on this problem for a while. Help would be much appreciated.
From: Andy on 28 Jun 2010 16:53
% If I understand correctly: grades = [1 5 85; 2 7 70; 3 2 80; 4 12 91; 5 4 92; 6 2 68; 7 1 73; 8 11 82; 9 10 79]; A=grades(grades(:,2)<10,:); A=A(:,[1 3]); B=grades(grades(:,2)>=10,:); B=B(:,[1 3]); |