Data Extraction using Unique and find commands
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (0)
Siehe auch
Kategorien
Mehr zu Import, Export, and Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!