I have the following internal function handle:
f = @(t)f_0.*sin(alpha.*t).*cos(beta.*t);
I want to create an external N by 1 function handle called F that places f in alternating positions in F as follows:
F = @t[f(t); 0; f(t); 0; f(t); 0; … ]
I would like to do this with the following function:
function F = farray (f,N)
r = 2:2:N
F = @(t) [f(t); zeros(N-r, 1)];
end
This doesn’t produce the desired population method. Can this be done without a for loop or another MATLAB function like toeplitz()?
Create a
Nby1vector that contains0and1in alternating positions then multiply it byf(t):Another way to create the array: