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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by