Passing Variable Number of Arrays to a function with varargin
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I would like to have a function that will take either one array or a number of them merged into one array within the function, which will then be plotted. The beginning of it is as follows:
function temp_array = fft100v(first_array,varargin)
% Plots the first 100 frequencies in in_array
% This assumes that sample interval is 1000 samples per second
% If length of array is shorter or longer than 1000, pad or cut it as
% appropriate
len_orig = length(first_array);
if nargin > 1
for n = 2:nargin
temp = varargin{n};
if length(temp) ~= len_orig
error('Arrays not of equal length');
end
end
end
The program craps out at the line "temp = varargin{n}" for more than one input with "Index exceeds matrix dimensions". It DOES have the curly braces on the "n". Guess I don't know enough about cell arrays.
Thanks.
Doug Anderson
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!