How can i change this to a multiselect loop?
Show older comments
I have this code file that works but i would like to change it to multiselect and run a loop to process the data.
function [M1,YT] = read6840(fid)
[FileName, PathName]=uigetfile({'*.asc','Individual DAS Files (*.asc)'},...
'Select 6840 Word File');
fid=fopen([PathName FileName]);
info6840=textscan(fid,'%10s',43);
data6840=textscan(fid,'%15s %5s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %s %s %s',15000);
fclose(fid);
% Record Information
DATE =char(info6840{:}(1));
DATE=[DATE(4:5) '/' DATE(7:8) '/' DATE(1:2)]; %convert to MM/DD/YY
RECORD =char(info6840{:}(40));
CH =char(info6840{:}(41));
S=char(info6840{:}(42));
%LOCKON =char(info6840{:}(43));
% Assign Variables to Names
for n=5:38
eval([char(info6840{:}(n)) '=data6840{' num2str(n-2) '};'])
end
time6840=(0:1:length(XDOT)-1)'*.05;
% Assign Discrete Variables to Names
ZW=char(ZW);
STAT=char(STAT);
BUS=char(BUS);
This is how i attempted to change it. Based on another bit of code I have that successfully runs multiselect loop
function [M1,YT] = read6840(varargin)
if nargin==0
[FileName,PathName] = uigetfile('*.asc','Select 6840 Word File ','MultiSelect','on');
if isnumeric(FileName)
%User clicked cancel or closed the window
return
end
else
FileName = varargin{1};
if nargin > 1
PathName = varargin{2};
else
PathName = cd;
end
if nargin > 2
OutPath = varargin{3};
if exist(OutPath,'dir') ~= 7
mkdir(OutPath);
end
else
OutPath = PathName;
end
end
FileName = compose('%g',FileName);
NumOfFiles = length(FileName);
GoodFiles = 1:NumOfFiles;
SN = zeros(NumOfFiles,1);
T = zeros(NumOfFiles,1);
H = zeros(NumOfFiles,1);
C = zeros(NumOfFiles,1);
CH = cellstr(repmat('C',NumOfFiles,1));
MC = cellstr(repmat('UNK',NumOfFiles,1));
WS = cellstr(repmat('UNK',NumOfFiles,1));
WD = cellstr(repmat('UNK',NumOfFiles,1));
for inx=1:NumOfFiles %Multifile loop begin
fid=fopen(FileName);
info6840=textscan(fid,'%10s',43);
% if ~strcmp('6840',info6840{:}(3))
% %Not a 6840 file... skip and move on.
% fclose(fid);
% GoodFiles(inx) = -1; %Remove this entry from the good files list.
% continue
% else %Valid 6840 file
% data6840=textscan(fid,'%15s %5s %20s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %s %s %s %s %s');
% fclose(fid);
%
% % check data6840 for good data
% for ii=1:size(data6840,2)
% if isempty(data6840{1,ii})
% %Not a good file... skip and move on.
% GoodFiles(inx) = -1; %Remove this entry from the good files list.
% continue
% end
% end
% clear ii
%
% %If we get this far, this is a good file.
% end
% data6840=textscan(fid,'%15s %5s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %s %s %s',15000);
% fclose(fid);
% Record Information
DATE =char(info6840{:}(1));
DATE=[DATE(4:5) '/' DATE(7:8) '/' DATE(1:2)]; %convert to MM/DD/YY
RECORD =char(info6840{:}(40));
CH =char(info6840{:}(41));
SN=char(info6840{:}(42));
%LOCKON =char(info6840{:}(43));
% Assign Variables to Names
for n=5:38
eval([char(info6840{:}(n)) '=data6840{' num2str(n-2) '};'])
end
time6840=(0:1:length(XDOT)-1)'*.05;
% Assign Discrete Variables to Names
ZW=char(Z11LW);
STAT=char(STAT);
BUS=char(BUS);
end
Accepted Answer
More Answers (0)
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!