saving for loop results not working
이전 댓글 표시
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
채택된 답변
추가 답변 (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!