How to Use Edit Text in GUI in creating a filename?

Hello Guys,
My problem is how to create a filename through editText in GUI?
t1=str2double(get(handles.Start_Time, 'string')); t2=str2double(get(handles.End_Time, 'string'));
I would like to use these t1 and t2 values in creating a text file name as below
repot_path = fullfile(pathname,'\','TimeSignal_of_' t1 'sec_to_' t2 'sec''.txt');
% finally file name should be like 'TimeSignal_of_3sec_to_4sec.txt'
dlmwrite(repot_path,Data_TBP,'precision', '%.4f','newline','pc');
but I am getting an error.
Kindly please help me.
With Regards; Meera Kunden

1 comentario

Adam
Adam el 7 de Abr. de 2015
Editada: Adam el 7 de Abr. de 2015
Please format your code in a {} Code block and include any error messages you receive. It takes a lot more effort for us to read through unformatted code and then to find all you say at the end if "I am getting an error".
You shouldn't need to be putting '\' as an argument to fullfile though - one of the purposes of that function is to add in file separators specific to the machine in question.

Iniciar sesión para comentar.

Respuestas (1)

Ilham Hardy
Ilham Hardy el 7 de Abr. de 2015
repot_path = fullfile(pathname,['TimeSignal_of_' t1 'sec_to_' t2 'sec''.txt']);
Or
repot_path = [pathname '\TimeSignal_of_' t1 'sec_to_' t2 'sec''.txt'];

4 comentarios

Meera
Meera el 7 de Abr. de 2015
Hello Hardy,
Thank you for your quick response.
But still there is an error, it is not displaying t1 and t2 values. Blank space is visbile in place of t1 and t2 values.
Could not open file
C:\Users\uidr1651\Desktop\save_txt\TimeSignal_of_ sec_to_ sec.txt
can you please check it.
should I use num2str(t1)?
With Regards; Meera Kunden
Adam
Adam el 7 de Abr. de 2015
You do need num2str to put numbers in a string.
However, in your case t1 and t2 are the result of converting a string to a double so just remove the str2double from the assignments to t1 and t2.
Ilham Hardy
Ilham Hardy el 7 de Abr. de 2015
Adam: +1, I didn't notice the str2double part. Thanks.
Meera
Meera el 8 de Abr. de 2015
Hello Adam & Hardy,
Thank you very much. I got the correct output.
Adam - Thank you for correcting my mistakes in posting the questions.

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Preguntada:

el 7 de Abr. de 2015

Comentada:

el 8 de Abr. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by