need to compile outputs from for loop into array
显示 更早的评论
startYear = input('Pick a year to start the Array from. \n');
endYear = input('Pick a year to end the Array at. \n');
ctr=1;
yeararray = startYear:endYear;
outputarray = []
for n = yeararray
if IsLeapYear(n) == "True"
outputarray(ctr) = outputarray(ctr) + n;
ctr = ctr + 1;
end
end
disp(outputarray)
A couple pieces of code are missing from this but i think you can understand the process, im trying to grab Leap Years in between 2 points and compile them into and Array but are struggling to do so. I tried to compile them into an array using numel():
outputarray = zeros(1, numel(yeararray))
however this makes the array way too big for the amount of values it outputs and just provides me with a bunch of zeros that are filler. Any tips?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!