Help with a for loop and matrices

1 次查看(过去 30 天)
I currently have this code where SizeChem is a 24x7 matrix and newcolum is a 24x1 matrix.
newcolumn = sum(SizeChem,2);
for i = 1:length(SizeChem)
T(i) = sum(newcolum(1:i,1));
end
I am wanting to create some arrays or variables that are the sum of the new column but summing one more row than the last. Then I want to take all those individual values and put them back into a matrix (24x1) starting with T{1} thru T{24}. I am also getting the error:
Undefined function or variable 'newcolum'.
Error in Analysis_plots (line 26)
T(i) = sum(newcolum(1:i,1));
I am not sure why this is. Thanks for the help in advanced.

采纳的回答

Rajat Gupta
Rajat Gupta 2019-6-25
It should be newcolumn instead of newcolum in your loop body.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by