Wrote a little function to generate random frequency sine tones. I would like each tone generated to be output into the workspace as a variable with name determined by output and input arguments and randomly generated variables (namely, tone freqency). I figured how to put the generated tones into a cell, but that's not what I want; I just want the simple, discrete audio vectors (1 x Nsamples), etc.
Comment lines in the code below explain what I'm trying to achieve a bit further. I KNOW this is a very simple thing, but the solution escapes me, and I'm not sure where to look in the documentation.
Thanks in advance!
function [Signal] = SineWave(Flower, Fupper, Amp, Fs, Time, NumTones)
for i = 1 : NumTones
Frequency = randi([Flower Fupper]);
t = 0:1/Fs:Time;
Signal = Amp * sin(2*pi*Frequency*t);
sound(Signal, Fs)
pause(Time)
end
1 Comment
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/609206-how-to-output-and-name-variables-generated-in-for-loop-into-workspace#comment_1050126
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/609206-how-to-output-and-name-variables-generated-in-for-loop-into-workspace#comment_1050126
Sign in to comment.