I want to add column 1st from data1 and coloumn 1st from data2, likewise addition of all coloumn.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sunil Oulkar
am 1 Mär. 2016
Bearbeitet: Stephen23
am 1 Mär. 2016
DATA1
4 8 6
3 5 7
1 9 2
DATA2
7 8 4
5 2 4
1 7 9
0 Kommentare
Akzeptierte Antwort
Stephen23
am 1 Mär. 2016
Bearbeitet: Stephen23
am 1 Mär. 2016
MATLAB makes these things really easy:
>> A = [
4 8 6
3 5 7
1 9 2];
>> B = [
7 8 4
5 2 4
1 7 9];
>> A + B
ans =
11 16 10
8 7 11
2 16 11
Note that it would probably be a bad idea to create three separate variables: programming is easiest when you keep your data together as much as possible (e.g. in one array, like I show), because then you can loop and apply to functions to an entire array.
0 Kommentare
Weitere Antworten (1)
Explorer
am 1 Mär. 2016
Bearbeitet: Explorer
am 1 Mär. 2016
DATA1= [4 8 6; 3 5 7; 1 9 2]
DATA2= [7 8 4; 5 2 4; 1 7 9]
C1_sum=DATA1(:,1)+DATA2(:,1) % Sum of 1st Columns of DATA1 and DATA2
C2_sum=DATA1(:,2)+DATA2(:,2) % Sum of 2nd Columns of DATA1 and DATA2
C3_sum=DATA1(:,3)+DATA2(:,3) % Sum of 3rd Columns of DATA1 and DATA2
2 Kommentare
Siehe auch
Kategorien
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!