フィルターのクリア

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

1 回表示 (過去 30 日間)
Laura Albers
Laura Albers 2018 年 4 月 11 日
回答済み: Ameer Hamza 2018 年 4 月 21 日
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 Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by