How to find a corresponds value?

조회 수: 1 (최근 30일)
Wiktoria Schabek
Wiktoria Schabek 2021년 11월 18일
답변: dpb 2021년 11월 18일
I have a big .csv file (like 30 000 data) which one I import to matlab (to import i used "readtable"). In one colum are current, in second voltage and in third radiation value. In matlab script im making a power value, then im looking for the max Power value, after that i need to find a radiation value which corresponds in the file to the value of the maximum power and thats where the problem begin. I am making m= max(power_value) and i dont know how to find value of radiation which corresponds to that m. How can i find it?

채택된 답변

David Hill
David Hill 2021년 11월 18일
[maxPower,idx]=max(yourMatrix(:,1).*yourMatrix(:,2));
radAtMaxPower=yourMatrix(idx,3);

추가 답변 (1개)

dpb
dpb 2021년 11월 18일
Use the optional second return value of max
[mx,imx]=max(t.Power);
rmx=t.Radiation(imx);
NB: the use of the table, t variable and dot reference directly instead of making duplicate copies of the data in the table as standalone arrays.
See the doc for max for all the details.
MORAL: Always read the documentation FIRST!; MATLAB may already have the solution at hand.

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by