How to write a code in M file for the variable name that constantly change with the file name
Show older comments
Hello,
Recently I created an M file (see below) to help me do FFT to a bunch of text files (with different names) containing waveforms. In each run, I want to use the variable (replaced with $$$$$$$$ as below) in the workspace that has the same name as the file name. How can I do it?
Thanks
-------------------------------------------------------------------------------
subject = {'JJG'} ;
modulation_depth = {'100'; '50'; '25'; '12.5'; '6.25'; '0'};
trace = {'1'; '2'};
for i = 1:length(subject)
subject_char = char(subject(i));
for j = 1:length(modulation_depth)
modulation_depth_char = char(modulation_depth(j));
for k = 1:length(trace)
trace_char = char(trace(k));
filename = strcat(subject_char, '_', modulation_depth_char, '_',
trace_char, '.txt');
load (filename);
Y = fft($$$$$$$)/4096;
FFT = 2*abs(Y(1:4096/2+1))
FileName = strcat(subject_char, '_', modulation_depth_char, '_',
trace_char, '_spec.txt');
Save_Command = ['save ' FileName ' FFT -ascii'];
eval(Save_Command);
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Standard File Formats in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!