Create array based on a loop setting a variable
显示 更早的评论
Hi, I hope I am able to explain my situation well enough to receive help. I am just starting with Matlab and basically a complete newbie.
I imported a table with two columns and 104 rows from an Excel sheet. It contains measured data of the variables I and U, so 104 values for I and 104 values for U.
To work with this table (called "A), I created two arrays:
I=A(1:104,1);
U=A(1:104,2);
So I and U are two arrays with the size of 104x1.
Now I need to multiply each row of I with each row of U and ideally get another array with the size of 104x1. To multiply each row individually, I created a small loop
for i=1:104
P=I(i)*U(i);
end
This works, but to my understanding, it just sets the variable P to the last result of the multiplication (of row 104).
I need to save every result of each multiplication to an array, but I can't find a function to do this. Any help is appreciated, thank you in advance!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
