How to write out multiple mat files, for some kind of regression suite testing?

1 view (last 30 days)
It will much easier to understand, if I use an example to demonstrate the problem I have :
Diff_Freq_Array = [5, 8, 10, 12, 14];
for i = 1: length(Diff_Freq_Array)
Freq = ((Diff_Freq_Array(i)) .* ones(1, 1000));
Phase = cumsum(Freq);
save ('output_variables', '-mat');
end
So, as described above in the script, I want to generate different frequencies as per the given numbers in the Diff_Freq_Array i.e. 5 hz, 8 hz, 10 hz and so on. Every-time this for loop is executed I want to save a different mat file (with a different name) for only that particular run. So at the end of the run, I should have total of 5 mat files for 5 frequency values in the Diff_Freq_Array. Please provide any insight, how to achieve that?

Accepted Answer

Iman Ansari
Iman Ansari on 16 Apr 2013
Edited: Iman Ansari on 16 Apr 2013
Hi
Diff_Freq_Array = [5, 8, 10, 12, 14];
for i = 1: length(Diff_Freq_Array)
Freq = ((Diff_Freq_Array(i)) .* ones(1, 1000));
Phase = cumsum(Freq);
name=['output_variables_' num2str(Diff_Freq_Array(i))];
% or
% name=sprintf('output_variables_%d',Diff_Freq_Array(i));
save (name,'Phase','Freq');
end

More Answers (0)

Categories

Find more on Startup and Shutdown 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!