Subtraction of a constant from a matrix column

42 ビュー (過去 30 日間)
Filip Davidovic
Filip Davidovic 2017 年 10 月 5 日
回答済み: SUJEET KUMAR 2023 年 9 月 15 日
Hi all, I'm trying to subtract a constant from every element in a matrix column, as the title suggests. The code I have is the following, however it does not work:
ver(:,1) = ver(:,1)-X;
Example. If we take ver = [1 2 3 ; 4 5 6], and X=3. So what I want to get by this subtraction is ver = [-2 2 3 ; 1 5 6].
Any help is appreciated. Thanks in advance! Cheers!

回答 (2 件)

KL
KL 2017 年 10 月 5 日
編集済み: KL 2017 年 10 月 5 日
It works for me
>> ver = [1 2 3 ; 4 5 6]
X = 3
ver =
1 2 3
4 5 6
X =
3
>> ver(:,1) = ver(:,1)-X
ver =
-2 2 3
1 5 6
What do you mean by it doesn't work?
  3 件のコメント
NN
NN 2020 年 12 月 17 日
how to subtract that constant from all the elements in that matrix?
NN
NN 2020 年 12 月 17 日
how can i subtract a 1*9 matrix from 576*9 matrix

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


SUJEET KUMAR
SUJEET KUMAR 2023 年 9 月 15 日
how to sum the all element in matric

カテゴリ

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