'Cutting off' beginning and end of a matrix
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Say I have a large matrix (numData) that is sorted consecutively by date, where column 4 is the year, column 5 is the month, and column 6 is the day. I need to separate the data by month (i.e. so all data for January is clumped together, etc). To do so, I've done the following:
jan = numData(numData(:,5)==1,1:end);
This works fine, but because numData can start at any day of the year, and end at any day of the year, I get an inconsistent number of years represented in each month clump. For example, with the data set I'm looking at now, numData starts in June and ends in October. For November-May I have 129 years worth of data, but for June-October I have 130. This becomes problematic for me later.
My best solution for this is to cut off the extra months and have everything start at the first appearance of January and end at the last appearance of December. So far as I can tell, this is an indexing exercise, which is something I'm terrible at. If anyone can give me an example of how to 'cut off' the beginning and end of a matrix like this, that would be greatly appreciated.
0 commentaires
Réponses (1)
madhan ravi
le 19 Oct 2018
Modifié(e) : madhan ravi
le 19 Oct 2018
numData(:,1)=[] %chops off 1st column
numData(:,end)=[] %chops off last column likewise for rows just interchange the index
0 commentaires
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!