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

1 次查看(过去 30 天)
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

回答(1 个)

Ameer Hamza
Ameer Hamza 2018-4-21

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);

类别

Help CenterFile Exchange 中查找有关 Language Fundamentals 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by