Filter löschen
Filter löschen

Select multiple ranges from a column and insert these into new column

1 Ansicht (letzte 30 Tage)
Laura Albers
Laura Albers am 11 Apr. 2018
Beantwortet: Ameer Hamza am 21 Apr. 2018
Hello!
I imported a full (38529x1) column containing Socio Economic Acocunts for 2014 into Matlab. However, I only want to take out certain ranges and insert them into a new column which will be called EMPE_2014. So the first range I want to extract from the full column ranges from 170:225, the second from 1066:1121 etc. Every range consists of 56 variables, and the difference between the ranges is the same as between the first and second I gave here above.
Does someone know how to create a new column containing 43 ranges, each range containing 56 variables? Thank you in advance

Antworten (1)

Ameer Hamza
Ameer Hamza am 21 Apr. 2018

It can be done as follow,

  • Generate the required indexes
interval = 55;
difference = 1066-170;
ind = [];
current_ind = 170;
while current_ind+difference<38529
  ind = [ind current_ind:current_ind+interval];
  current_ind = current_ind+difference;
end
  • Extract required values from the old vector
new_vector = old_vector(ind);

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by