Create array based on a loop setting a variable
Show older comments
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!
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!