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;

 채택된 답변

Guillaume
Guillaume 2018년 6월 15일
root = '\Drive1\Main\Trial\Test'
filename = sprintf('%d_%d_%d_%d_%g', A, B, C, D, E);
fullpath = fullfile(root, filename);

댓글 수: 3

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)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2018년 6월 15일

댓글:

2018년 6월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by