필터 지우기
필터 지우기

display the value from a vector

조회 수: 2 (최근 30일)
Costi Gilca
Costi Gilca 2016년 4월 24일
답변: Peta 2016년 4월 24일
Hello,
I have 2 vectors like this: a=[ 95 120 115 132 ...] b=[ 300 250 375 320 ...] Each set of values are associated so when I use minimum for the elements of first vector I want to display myself the value associated from the second vector: For example: if the minimum value in vector a is 95 I want to show me the 300 value, if the minimum is 115 I want to display 375 etc. Could anybody help me, please? Thank you

채택된 답변

Peta
Peta 2016년 4월 24일
This is what I usually do:
% Find the index of the minimum value in a and store it in the variable pos.
[~,pos] = min(a);
% Use pos to get the corresponding value from b:
b(pos)

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by