Subtracting 1 matrix from several columns in a larger matrix

1 回表示 (過去 30 日間)
Jamie England
Jamie England 2019 年 2 月 11 日
コメント済み: madhan ravi 2019 年 2 月 11 日
Hi all, this is probably an easy one but my minds gone blank. Basically I have a matrix 3553450x8 containing different measured data, I am looking to subtract 3 of these columns by a seperate matrix. anyone know how to do this, cheers
  2 件のコメント
madhan ravi
madhan ravi 2019 年 2 月 11 日
size of the other matrix?
Jamie England
Jamie England 2019 年 2 月 11 日
the other matrix would be 3553450x1

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

採用された回答

madhan ravi
madhan ravi 2019 年 2 月 11 日
M(:,1:3) - N
% ^^^---- represent three columns can be any three columns
%M is of size 3553450x8
%N is of size 3553450x1

その他の回答 (1 件)

aara
aara 2019 年 2 月 11 日
You could form a similar sized matrix of zeros, place the desired values which you wish to subtract from the original data and the perfrom the subtraction operation:
placeholder = zeros(3553450,8);
placeholder(:,i:j) = data_to_remove %choose i and j to be the columns you wish to subtract,
% they must be adjacent to each other.
%if data is not adjacent to each other then do them manually via:
placeholder(:,i) = column1_data_to_remove;
placeholder(:,j) = column2_data_to_remove;
placeholder(:,k) = column3_data_to_remove;
dataMatrix = dataMatrix - data_to_remove;
Save on memory by using a sparse matrix with the placeholder.

カテゴリ

Help Center および File ExchangeData Import and Management についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by