find maximum value indices
이전 댓글 표시
Im trying to find the indices number of the max of a certain function.
delcx(:,n) = (massch4(max(longm(dataind{n}))))
I want to find the massch4 at the location where longm is a max value. Can I do that in one line? Can I use the find function?
Thanks!
댓글 수: 10
per isakson
2015년 2월 10일
편집: per isakson
2015년 2월 10일
Why should we guess regarding massch4, longm and dataind? Please tell us about class, size and value. An example might be appropriate.
shobhit mehrotra
2015년 2월 10일
per isakson
2015년 2월 10일
편집: per isakson
2015년 2월 10일
- "Can I do that in one line?"   It's easier to break it up in small steps and confirm that it works correctly. Lastly, one may combine it into one line.
- "in an array"   cell array I assume
ixn = dataind{ n };
lgm = longm( ixn );
mxl = max( lgm );
ms4 = massch4( mxl );
mxl and ms4 will be scalars. Will lgm and mxl be whole number suitable as indicies? What did I miss?
shobhit mehrotra
2015년 2월 10일
편집: per isakson
2015년 2월 10일
per isakson
2015년 2월 10일
편집: per isakson
2015년 2월 10일
This looks strange! Why
ixn(n) = longm(dataind{ n });
rather than
ixn(n) = dataind{ n };
Isn't it time you
- start using the {}Code button and
- provide some sample data: input and required output
shobhit mehrotra
2015년 2월 10일
편집: per isakson
2015년 2월 10일
per isakson
2015년 2월 10일
편집: per isakson
2015년 2월 10일
Did you try it? Whether it will work or not depends on the input data. You might preallocate memory for indm.
indm = nan(1,20);
for n=1:20
indm(n) = find( longm == max(longm(dataind{n})) );
end
What happened to massch4?
shobhit mehrotra
2015년 2월 10일
shobhit mehrotra
2015년 2월 10일
per isakson
2015년 2월 10일
Replace
find( longm == max(longm(dataind{n})) )
by
find( longm == max(longm(dataind{n})), 1, 'first' )
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!