Borrar filtros
Borrar filtros

Change from file=input to no input required

2 visualizaciones (últimos 30 días)
Mariano Negron Perez
Mariano Negron Perez el 12 de Mayo de 2021
Comentada: Mariano Negron Perez el 20 de Mayo de 2021
Good afternoon,
I have a matlab code which requires user input every time I run it, and I run it so much that by now I always just input "1" as the name for the files; how can I alter this code so it saves to those files without user input? i.e. my input is always "1".
-----------------------------------------------------------------------------------------------------------------------------------------------------------
%File name to store data, e.g. 'myfile' or 'temp' or 'sardata'.
file=input('Enter root file name for data and listing files: ','s');
...
data_file=[file,'.mat'];
mystery_file=[file,'_mys.mat'];
listing_file=[file,'.lis'];
eval(['save ',data_file,' c tau W fs s Npulses PRF PRI T_out fc', ...
' Ta v lambda Rc u Rcrp Ls DR DCR Ntargets coords y t_y Nr txLFM txtotal rxSig SNR_radar_dB RCRdB Rs SRBR']);
eval(['save ',mystery_file,' c tau W fs s Npulses PRF PRI T_out fc', ...
' Ta v lambda Rc u Rcrp Ls DR DCR y t_y Nr txLFM txtotal rxSig SNR_radar_dB RCRdB Rs SRBR']);
fid=fopen(listing_file,'w');
...
fclose(fid);
fprintf(['\n\nData is in file ',data_file])
fprintf(['\nStudent data is in file ',mystery_file])
fprintf(['\nListing is in file ',listing_file,'\n\n'])

Respuesta aceptada

Bhavik Patel
Bhavik Patel el 20 de Mayo de 2021
It is my understanding that you want to freeze the value of a variable instead of requesting it from a keyboard.
Since you want to apply the same value to file variable in your code, replace the first line of your code with this:
file = '1'; % Specify a character vector as file name
Hope this helps!

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by