reshaping to display the same result of a function
1 view (last 30 days)
Show older comments
I want the following function to be reshaped in a different manner:
for i=1:length(b)
mn(i)={min(reshape(b{i}(:,5),60,[])).'};
mx(i)={max(reshape(b{i}(:,6),60,[])).'};
end
This code breaks the rows into a group of 60 and then finds the max or min value. I, however, would like to reshape in such a way that the min value is found for the 60 rows and then the min value is given for each of these 60 rows rather than giving one value. For instance,
1
3
4
5
67
8
The min value of this column is 1. I want the result to be displayed in such a manner:
1 1
3 1
4 1
5 1
67 1
8 1
0 Comments
Accepted Answer
dpb
on 9 Nov 2014
My initial answer was written to do that but then I looked at the code you had written and followed your lead of the two vectors... :)
for i=1:length(b)
mnmx(i)={[min(reshape(b{i}(:,5),60,[])).' ...
max(reshape(b{i}(:,6),60,[])).']};
end
Concatenate the two column vectors before turning into a cell.
4 Comments
dpb
on 9 Nov 2014
So, what specific calculations actually require the duplicated values?
Specifically,
doc bsxfun
for one particular case of singleton expansion to avoid the explicit arrays.
We can't suggest other alternatives if hide the information on what the next step is from us, though... :(
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown 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!