フィルターのクリア

Adjust size of vector/matrix

33 ビュー (過去 30 日間)
Deepak Sapkota
Deepak Sapkota 2019 年 2 月 22 日
コメント済み: Kevin Phung 2019 年 2 月 22 日
Hello, How can I choose a vector array with first 50 elements? Eg: Say I have vector A with 1x50 dimension and B with 1x60. How can I make dimension of B same to A such that B will have first 50 elements? I tried using resample (B,50,60) but it seems that it choose 50 elements randomly, with some repetition. Is using imresize correct?
Any help will be appreciated.
Thank you in advance.
  3 件のコメント
Jos (10584)
Jos (10584) 2019 年 2 月 22 日
Is there a relationship between A and B? Do you want to change the elements of the new B, or truncate B?
A simple example:
A = [1 2 3]
B = [10 20 30 40 50 60]
What do you want B to look like in the end? [10 20 30], [10 35 60]?
Deepak Sapkota
Deepak Sapkota 2019 年 2 月 22 日
Thank you everyone. A and B are related. I found what I was looking for. It was new vec_B=old_B(:,1:50). And this picks first 50 elements.

サインインしてコメントする。

採用された回答

Kevin Phung
Kevin Phung 2019 年 2 月 22 日
編集済み: Kevin Phung 2019 年 2 月 22 日
f you want to set the first 50 elements of B to be equal to A:
B(1:50) = A;
If you mean to delete excess elements in B until you get to the same size as A:
B = B(1:numel(A)); % this will turn B from 1x60 to 1x50,
% or whatever the number of elements in A is.
  2 件のコメント
Deepak Sapkota
Deepak Sapkota 2019 年 2 月 22 日
Thank you Kevin Phung
Kevin Phung
Kevin Phung 2019 年 2 月 22 日
you're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by