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

조회 수: 1 (최근 30일)
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?

채택된 답변

Iman Ansari
Iman Ansari 2013년 4월 16일
편집: Iman Ansari 2013년 4월 16일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by