I have two 1x128 matrices. I want to substract them, but only for specific columns (For examples for columns 1 to 50 and 90 to 128.

1 回表示 (過去 30 日間)
I have two 1x128 matrices (data1 and data2). I want to subtract data2 from data1, but only for specific columns (For examples columns 1 to 50 and 90 to 128. And then store this as data3 as a new 1x128 matrix. Can anyone help me please?
  2 件のコメント
Guillaume
Guillaume 2018 年 3 月 5 日
So what goes into column 51 to 89 of the result?
Stephen Jeffreys
Stephen Jeffreys 2018 年 3 月 5 日
Sorry I should have mentioned, the values from the data1 matrix

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

回答 (2 件)

Guillaume
Guillaume 2018 年 3 月 5 日
data3 = data1;
data3(:, [1:50, 90:128]) = data1(:, [1:50, 90:128]) - data2(:, [1:50, 90:128]);
or the other way round:
data3 = data1 - data2;
data3(:, 51:89) = data1;
  1 件のコメント
Stephen Jeffreys
Stephen Jeffreys 2018 年 3 月 5 日
I was missing the comma in the code %([1:50, 90:128])
Thank you so much, I really appreciate this. Best, Stephen

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


elham kreem
elham kreem 2018 年 3 月 6 日
let :
a=1:128
b= 2: 129
z= b(1, [1:50,90:128]) - a(1,[1:50,90:128])

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by