generate filepath for opening file from user selected listbox inputs

I am trying to use user selected inputs to find a specific filename/location.
I have a large number of tests stored in a folder and I want a specific file to be loaded depending on the user inputs to use for subsequent analysis.
The filenames have common string with variable values based on the value of what is tested. What I want is to use the selected user input to fill the variable values to build a filename to load based on what is entered,
Example filename: Filename = ‘\Drive1\Main\Trial\Test\70_205_1800_445_5.6.csv
Where 70, 200, 354, 1.3, 500 are variables of the test
The GUI gives a better understanding on what i'm trying to achieve
Look to accomplish:
A = 70;
B = 205;
C = 1800;
D = 445;
E = 5.6;
Filename_Common = ‘\Drive1\Main\Trial\Test\';
Filename_constructed = Filename_Common,A_B_C_D_E;
Filename = filename_constructed;

 Respuesta aceptada

root = '\Drive1\Main\Trial\Test'
filename = sprintf('%d_%d_%d_%d_%g', A, B, C, D, E);
fullpath = fullfile(root, filename);

3 comentarios

That worked perfectly.
Is there a way to link the selected value in the listbox to the Variable (A,B,C etc...) on the pushbutton.
Thanks
Is there a way to link ...
I don't understand what you mean by that.
sorry, how to use the selected value in the listbox as the variable.
i.e. A = Listbox selected value (70)

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 15 de Jun. de 2018

Comentada:

el 20 de Jun. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by