How to generate text file in specific path

I have the following code
if (app.ChooseSourceDropDown.Value=='S1')
sub_chs1=chs1(app.MinimumChannel.Value:app.MaximumChannel.Value, 1);
Es1=c+d.*sub_chs1;
M=[chs1 abss1 Es1];
fid = fopen('DataS1_ch_count_E.txt','w');
fprintf(fid,'%f\t %f\t %f\r\n',M');
fclose(fid);
where chs1,abss1,Es1, are vector of data
I used the previous code to generate a text file the problem is that the file is generated at my selection in Current Folder, while i have a certain path that i want it to be generated in. the path is changable because it is generated by bowse button and i have that path named in variable. i want to know how to generate this text file in that variable that consist of path.
knowing that I am using app designer

Réponses (1)

per isakson
per isakson le 25 Nov 2018
Replace
fid = fopen('DataS1_ch_count_E.txt','w');
by
filespec = fullfile( path_named_in_variable, 'DataS1_ch_count_E.txt' );
fid = fopen(filespec,'w');

Catégories

En savoir plus sur Variables dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by