Elementwise addition operation in matrix or array
Mostrar comentarios más antiguos
BD is 33*3 data.
BD=[ 1 0 0
2 100 60
3 90 40
4 120 80
5 60 30
6 60 20
7 200 100
8 200 100
9 60 20
10 60 20
11 45 30
12 60 35
13 60 35
14 120 80
15 60 10
16 60 20
17 60 20
18 90 40
19 90 40
20 90 40
21 90 40
22 90 40
23 90 50
24 420 200
25 420 200
26 60 25
27 60 25
28 60 20
29 120 70
30 200 600
31 150 70
32 210 100
33 60 40];
BD(:,2)
I want to add data element wise in 2nd column and replace the data in BD.
Suppose addtion of 100 in BD (2,2) should update BD(2,2) to 200. Remaining column data should be as it is.
P(2)=100
BD(:,2) = BD (:,2)+_________
1 comentario
Sanket Raval
el 10 de Feb. de 2022
Respuestas (1)
David Hill
el 10 de Feb. de 2022
If you are just adding a scalar to column 2 of BD
BD(:,2)=BD(:,2) + Scalar;
2 comentarios
David Hill
el 10 de Feb. de 2022
If P is the same length as B, then
BD(:,2)=BD(:,2)+P;
If P is a different length
m=min(size(B,1),length(P));
BD(1:m,2)=BD(1:m,2)+P(1:m);
Sanket Raval
el 11 de Feb. de 2022
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!