Not Enough Input Arguments
2 views (last 30 days)
Show older comments
Hi, I am new to Matlab and I am facing an error while generating a signal which i hae to use in other programs as well,
Here is the code which I am using to create signal,
if ~exist('coherence', 'var')
coherence = false;
rng('default')
end
if ~exist('nSamples', 'var')
nSamples = 1e3;
end
if ~exist('amplitudes', 'var')
amplitudes = zeros(1,numel(xPos));
end
if ~isvector(xPos)
error('X-positions of array elements must be a 1xP vector where P is number of elements')
end
if ~isvector(yPos)
error('Y-positions of array elements must be a 1xP vector where P is number of elements')
end
if ~isvector(zPos)
error('Z-positions of array elements must be a 1xP vector where P is number of elements')
end
T = nSamples/fs;
t = 0:1/fs:T-1/fs;
signalTotal = 0;
for k = 1:numel(thetaArrivalAngles)
%Create signal hitting the array
doa = squeeze(steeringVector(xPos, yPos, zPos, f, c, thetaArrivalAngles(k), phiArrivalAngles(k)));
%Add random phase to make signals incoherent
if coherence
signal = 10^(amplitudes(k)/20)*doa*exp(1j*2*pi*f*t);
else
signal = 10^(amplitudes(k)/20)*doa*exp(1j*2*pi*(f*t+randn(1, nSamples)));
end
%Total signal equals sum of individual signals
signalTotal = signalTotal + signal;
end
When i run this program, I get the error shown below. I have no idea how to resolve it. Please can someone help me with this
Not enough input arguments.
Error in createSignal (bold part in code)
amplitudes = zeros(1,numel(xPos));
0 Comments
Answers (1)
Jan
on 7 Mar 2019
The message means, that xPos is not defined. I guess, that you forgot to provide input arguments to your function. Maybe you have pressed teh "Run" button in the editor, but a function must be called with input arguments.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!