Hi Please explain what function is eval performing here and is it necessary to use it. I'm planning to use eval function to store code book, is there any alternative.
clc; Nsamp=35000; fs=8050; beep I=wavrecord(Nsamp,fs);
codebook = MFCC_BasedCodebook(I,fs); in=inputdlg('Enter file name -5 characters'); FileName=cell2mat(in); eval(['save ' 'test\' FileName ' codebook;']);
Thank you

댓글 수: 1

Stephen23
Stephen23 2026년 5월 27일 4:04
편집: Stephen23 2026년 5월 27일 9:00
"... is it necessary to use it."
It is not necessary to use it, its usage here marks this code as being extremely badly written.
"I'm planning to use eval function to store code book, is there any alternative."
save(fullfile('test',in{1}),'codebook')

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

 채택된 답변

lvn
lvn 2014년 4월 23일

0 개 추천

Eval can be used to run matlab commands which are not known in advance, but only at runtime. In your example eval executes the commando 'save test\FileName codebook' (with filename the specific filename constructed above).
The use of eval is not recommended http://www.mathworks.nl/help/matlab/matlab_prog/string-evaluation.html and in your case, it can simply be replaced by using the different syntax of the save commando ('help save') e.g.
save(sprintf('test\\%s',FileName),'codebook');

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming Utilities에 대해 자세히 알아보기

태그

질문:

2014년 4월 23일

편집:

2026년 5월 27일 9:00

Community Treasure Hunt

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

Start Hunting!

Translated by