Data Extraction using Unique and find commands

조회 수: 1 (최근 30일)
Sai Gudlur
Sai Gudlur 2020년 2월 18일
댓글: Jacob Wood 2020년 2월 18일
Hello,
I have a huge data set. One of the main columns are are "byprog" & "FDR". I have the prog structured in way that user can select data on the basis of Program Name and FDR. Untill now I was looking for status saying "Accept" the Last status based on the time stamp and extracting data but now i have run into a road block where each Program has one FDR and was tested multiple times and has multiple accepts. Now when i use unique function [c,ia,ib] my ib only lets me pick either "first" or "last" "accept" data rather than all "accept" data. Could someone help me with this. Have attached part of the file and my code. Any help would be appreciated.
clear;
[filename,pathname]=uigetfile('*.xlsx');
[~,sheets]=xlsfinfo(fullfile(pathname,filename));
[Sel,v]=listdlg('PromptString','Select Desired Sheet',...
'SelectionMode','single','ListString',sheets);
[data,textdata,raw]=xlsread(fullfile(pathname,filename),Sel);
headers = (textdata(2,:));
byprog = textdata(3:end,2);
[c,ia,ib] = unique(byprog,'stable');
FDR = find(strcmp(headers,"Warm Up Axle Setup Axle Ratio"));
Test_Status = find(strcmp(raw(2:end,6),"Accept"));
cfdr={};
for i=1:size(c,1)
thisindex=find(ib==i,1,'last'); % I want to have all instead of 'last' or 'first'.
tfdr=raw(thisindex+2,FDR);
cfdr=[cfdr; {sprintf('%s (FDR: %.2f)',c{i,1},tfdr{1,1})}];
end
[indx,tf] = listdlg('PromptString',{'Select a file.',...
'Only one file can be selected at a time.',''},...
'SelectionMode','single','ListString',cfdr);
lastindex = find(ib==indx,1,'last');%
Status = textdata(lastindex,6);
  댓글 수: 1
Jacob Wood
Jacob Wood 2020년 2월 18일
Instead of unique() can you use logical indexing?

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by