creating matrix using output elements
2 views (last 30 days)
Show older comments
okoth ochola
on 19 Jan 2023
Commented: Fangjun Jiang
on 20 Jan 2023
Hi, i havecode below which ouputs given values independently. however, i want the ouputs to be under one matrix,what can i add to the code to do this job. B is an n by 1 matrix say B=[1:1:24]'. How can I collect all the values of Hourly_mean to form one matrix? kindly assist. Thank you
B=[1:1:576]'
for k=1:1:numel(B)
Hourly_mean=mean(B(k:24:end))
end
[Hourly_mean]
0 Comments
Accepted Answer
Fangjun Jiang
on 19 Jan 2023
B=[1:1:576]';
mean(reshape(B,24,[]))
3 Comments
Fangjun Jiang
on 20 Jan 2023
@Steven Lord, good catch! mean(C,2) is more likely the needed outcome than mean(C).
More Answers (1)
See Also
Categories
Find more on Linear Algebra 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!