Making a new variable

15 次查看(过去 30 天)
LacAnthony
LacAnthony 2019-10-2
评论: LacAnthony 2019-10-2

Hello, I would like to make a new variable from existing variables. What I want to do is sum up the first column of 3 variables that I have already made and make 1 new variable with the sums in a 1x3 row.

采纳的回答

David Hill
David Hill 2019-10-2
newVar=[sum(first(:,1),sum(second(:,1),sum(third(:,1)];

更多回答(1 个)

Walter Roberson
Walter Roberson 2019-10-2
new_variable = [sum(first_variable(:,1)), sum(second_variable(:,1)), sum(third_variable(:,1))];
There is another approach that is slightly more compact but requires that the variables be the same size; the above code does not require that.

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by