Filter löschen
Filter löschen

Can I define a directory by pulling names from cell arrays?

5 Ansichten (letzte 30 Tage)
Scooby921
Scooby921 am 16 Jul. 2019
Bearbeitet: Scooby921 am 16 Jul. 2019
I'm not sure I'm approaching my scripting the right way as I've run myself into a corner and can't find a way out. Script posted below. I'm asking the user to select the top level directory of data to be analyzed. Under this top level directory there are sub folders which identify each performance mode tested in a vehicle. These sub folders are created by copying a default and renaming. The default folder contains the necessary sub-structure of folders to divide data into specific tests.
Once the top level is identified the script finds the sub folders immediately under this directory. This populates a list of performance modes (modeList). Next the sections prompt the user to select a driveline configuration (hardware type) and which test specific test they want to analyze. This is where I'm stuck. I either can't find or can't search for the correct syntax to figure out how to get from my known top level directory into the selected test folder for all available and tested performance modes.
%% Initialize
close all
clear
clc
%% Select path and generate list of modes
% Prompt user to identify top level directory for the vehicle to be
% analyzed.
vehiclePath = uigetdir('','Select Vehicle Data Directory');
% Extract sub folder names which should identify the number and name of
% various performance modes tested in the selected vehicle. Ignore ., ..,
% and default folder names.
pathContents = dir(vehiclePath);
folders = pathContents(~ismember({pathContents.name},{'.','..','4WD -insert mode name-'}));
dirFlags = [folders.isdir];
subFolders = folders(dirFlags);
modeList = {subFolders.name};
clearvars pathContents folders dirFlags
%% List Generation
% List of AWD hardware variants
variantList = {'Booster','Twinster'};
% List of all standardized test maneuvers used for validation. This list
% matches the sub folders contained within each performance mode (second
% level folders named in 'modeList' above).
testList = {'VVT_001 Path Deviation',...
'VVT_002 High Mu CRAM',...
'VVT_003 High Mu Acceleration',...
'VVT_004 Torque Steer Evaluation',...
'VVT_005 Undefined',...
'VVT_006 Sine Steer',...
'VVT_007 High Mu AIT 90deg',...
'VVT_008 High Mu AIT 45deg',...
'VVT_009 Low Mu Acceleration',...
'VVT_010 Low Mu Tip-In 50kph',...
'VVT_011 Low Mu Tip-In 100kph',...
'VVT_012 AWD Response Time',...
'VVT_013 Level MuSplit',...
'VVT_014 Level MuStep',...
'VVT_015 10% MuSplit Grade',...
'VVT_016 15% MuSplit Grade',...
'VVT_017 20% MuSplit Grade',...
'VVT_018 30% MuSplit Grade',...
'VVT_019 Micro MuSplit 50% Throttle Tip-In',...
'VVT_020 Micro MuSplit WOT Tip-In',...
'VVT_021 Low Mu CRAM',...
'VVT_022 Small Ice Circle AIT',...
'VVT_023 Small Ice Circle DTIT',...
'VVT_024 Small Snow Circle AIT',...
'VVT_025 Small Snow Circle DTIT',...
'VVT_026 Large Ice Circle AIT',...
'VVT_027 Large Ice Circle DTIT',...
'VVT_028 Large Snow Circle AIT',...
'VVT_029 Large Snow Circle DTIT'};
%% Variant Selection
% Prompts user to identify which type of AWD system was equipped for
% testing. This impacts calculations and plots which execute in other
% scripts.
[variant,TF] = listdlg('ListString',variantList,'ListSize',[220,100],'Name','Select Variant','SelectionMode','Single');
if TF == 0
Err = errordlg('No Variant Selected','Analysis Canceled');
set(Err,'Position',[600 600 200 60]);
return
else
end
drivelineConfig = variantList{variant};
clearvars TF
%% User Selection
% Prompts user to idenfity which test is to be analyzed.
[test,tf] = listdlg('ListString',testList,'ListSize',[300 600],'Name','Select Comparison Maneuver','SelectionMode','Single');
if tf == 0
err = errordlg('No Analysis Selected','Analysis Canceled');
set(err,'Position',[600 600 200 60]);
return
else
end
selectedTest = testList{test};
clearvars tf
I have the top level directory. Just for example call it 'C:\Vehicle Data\Buick Lacrosse'. My 'modeList' variable is a cell array and defines the second level folders. In this case they'll be "2WD" and "4WD". Then from the list dialog I end up with variable 'Test' which can be used to identify the lowest level folder name in my 'testList' cell array. Can I append the names from cell arrays to the top level directory to create 'C:\Vehicle Data\Buick Lacrosse\2WD\VVT_009: Low Mu Acceleration' and 'C:\Vehicle Data\Buick Lacrosse\4WD\VVT_009: Low Mu Acceleration'? If not, is there a way to get from a user identifying a top level folder to my script finding the appropriate lowest level folders containing the data (.mat files) to be analyzed? The caveat here is that not all data is analyzed in the same way. I can't use a blanket that searches for any and all .mat files and runs the same analysis.
  3 Kommentare
Steven Lord
Steven Lord am 16 Jul. 2019
Use fullfile instead of strcat as it automatically will handle including the correct filesep character for your platform.
Scooby921
Scooby921 am 16 Jul. 2019
Bearbeitet: Scooby921 am 16 Jul. 2019
Fantastic. Thank you!

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by