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

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Iman Ansari
Iman Ansari il 16 Apr 2013
Modificato: Iman Ansari il 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

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by