Indexing Row from Excel File to Relate Multiple Columns
13 views (last 30 days)
Show older comments
I have a fairly large Excel file, 7907x27. I have gone ahead and made vectors of each column because they pertain to different data representations, so I don't need to use xls read any more (unless it'll reduce run time or solve my problem).
For the sake of this problem and clarification, lets say all of the data points in each column are entirely random with values ranging anywhere between 0 and 1000, though they are relative to only their column.
What I'm trying to do, is take only the data from Column4 that is between 0 and 10, Create a vector to index the row values for which these values are within the range. Then take the newly created index and display the results from Column15 that relate to the appropriate;y related recently indexed rows. And I need to do this multiple times for all possible values of the original Column4.
My code was generating a recursive loop, so I've deleted some lines, and I'm not sure what lines of code I need to use. What I've been working on looks similar to as follows:
m=size(Column1);
for i=1:m
if Column4(i)<10
Name=Column15(i);
elseif Column4(i)>10
while Column4(i)<200
Name2=Column15(i);
end
elseif Column4(i)>200
while Column4(i)<1000
Name3=Column15(i);
end
elseif Column4(i)>1000
while Column4(i)<2000
Name4=Column15(i);
end
end
end
Any ideas?
1 Comment
per isakson
on 4 Oct 2015
Edited: per isakson
on 4 Oct 2015
"What I'm trying to do, is take only the data from Column4 that is between 0 and 10, Create a vector to index the row values for which these values are within the range."   Try this
C4 = randi([0,1000],[7907,1]);
index_vector = find( C4>=0 & C4<=10 );
C4( index_vector(1:8) )'
ans =
0 1 4 8 4 7 1 4
Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!