Import CSV files, find extraction condition, and local maxima
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi everyone,
I am trying to read in multiple .csv files with lot of data (mostly numbers except : the first row contains 2 strings and several numbers, and these first row numbers are actully the same in every .csv)
After that I have to find in the first row the value '50' and get its column and then find the local maxima in that.
Can you pls help me, how to solve this?
Thanks in advance.
댓글 수: 4
채택된 답변
Image Analyst
2020년 6월 18일
Grace:
This should do it:
% Create sample matrix.
m = randi(500, 100, 30);
% Find out all the rows that have a 50 in them.
rowsWith50 = find(any(m == 50, 2))
% If any row(s) do, then find the column with the 50 in it,
% and get the max of that column.
if ~isempty(rowsWith50)
firstRowWith50 = m(rowsWith50(1), :);
% Get its column
columnWith50 = find(firstRowWith50 == 50, 1, 'first')
% Find the max of this column over all rows
theMax = max(m(:, columnWith50))
end
댓글 수: 4
Image Analyst
2020년 6월 19일
편집: Image Analyst
2020년 6월 19일
This seems to work fine to read in the matrix
data = readmatrix('dataset.csv', 'numHeaderLines', 1)
fprintf('Done running %s.m ...\n', mfilename);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!