saving for loop results not working
Show older comments
Hi everyone, I'm struggling to save my results from a FOR loop. I have watched some videos and look at other peoples questions to try and find what I'm missing (which is probably something simple) but I can't get it to work. I have tried the following codes
I = 800/365*1.5;
O = 400*17000/1000000;
d = 1:3;
sc = 8;
sum = zeros(length(d),1);
for d = 1:length(d)
sc = sc+I-O;
sum = sc
end
Thi code keeps doesn't save all 3 results.
I = 800/365*1.5;
O = 400*17000/1000000;
sc = 8;
for d = 1:3
sc(d) = sc+I-O;
end
This code keeps saying there are different elements between right side and left side.
Can anyone please explain to me what im doing wrong and how to fix it. All I want is to do a loop for 3 counts (3 days) where full capacity is 8 of a tank, and eveyday there is an infow and an outflow. I would like to show the results in 3x1 table along with the inflow of every day and the outflow of everyday (both which will be constant).
thanks
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!