필터 지우기
필터 지우기

Change from file=input to no input required

조회 수: 2 (최근 30일)
Mariano Negron Perez
Mariano Negron Perez 2021년 5월 12일
댓글: Mariano Negron Perez 2021년 5월 20일
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'])

채택된 답변

Bhavik Patel
Bhavik Patel 2021년 5월 20일
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!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by