How can store data when a function provide answer with different sizes.
1 view (last 30 days)
Show older comments
I want to apply a function called extrema that have this way: [xmax, imax, xmin, imin]=extrema (x); but a i have a matrix that have this dimensions: 3500X6 and I want to apply this function in each column, so, six times. However, the answer to each extrema provide me a matrix with different sizes and that way, I can't to do my job. This is the code:
for i=1:NCf
[xmax(:,i),imax(:,i),xmin(:,i),imin(:,i)] = extrema(Graph(:,i));
end
??? Subscripted assignment dimension mismatch.
I though, in change the name of outputs each time that occur the loop, but I don't know how to do?
0 Comments
Accepted Answer
More Answers (1)
Jan
on 20 Sep 2011
An approach with cells:
xmax = cell(1, NCf);
imax = cell(1, NCf);
xmin = cell(1, NCf);
imin = cell(1, NCf);
for i=1:NCf
[xmax{i}, imax{i}, xmin{i}, imin{i}] = extrema(Graph(:,i));
end
0 Comments
See Also
Categories
Find more on Logical 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!