Filter löschen
Filter löschen

Addition inside of an existing Matrix

1 Ansicht (letzte 30 Tage)
Atreyu91
Atreyu91 am 23 Aug. 2015
Beantwortet: matico am 23 Aug. 2015
I am trying to understand how to manipulate a matrix, can anyone please show me how to perform the following action in Matlab?
for example if I had a 2x2 matrix
[a,b;c,d]
How would I be able to achieve
[a,b;c,x+d]
e.g a=1, b=2, c=3, d=4,
if X=10
[1,2;3,X+5]

Akzeptierte Antwort

matico
matico am 23 Aug. 2015
M = [1, 2; 3, 4];
X = 10;
%%VERSION 1
M(end) = M(end) + X;
%%VERSION 2
M(2,2) = M(2,2) + X;
In both versions the M matrix become [1, 2; 3, 14]

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by