필터 지우기
필터 지우기

How can store data when a function provide answer with different sizes.

조회 수: 1 (최근 30일)
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?

채택된 답변

Wayne King
Wayne King 2011년 9월 20일
Hi Alan, one way is to use cell arrays to store your data.
  댓글 수: 2
Alan
Alan 2011년 9월 20일
I tried but the Matlab said that is not a cell array
Wayne King
Wayne King 2011년 9월 20일
Hi Alan, you have to use the proper syntax for cell arrays.
xmax{i}

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2011년 9월 20일
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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by