Data Extraction using Unique and find commands
显示 更早的评论
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
2020-2-18
Instead of unique() can you use logical indexing?
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!