Borrar filtros
Borrar filtros

Not enough input arguments error

3 visualizaciones (últimos 30 días)
Riley Morris
Riley Morris el 30 de Ag. de 2022
Respondida: Chunru el 30 de Ag. de 2022
function [tVec,xVec]=fxNthOrderPolysignal(domainVec, rootsVec)
% create time vector
tVec = linspace(domainVec(1),domainVec(2),100);
%obtain polynomial coefficients p from roots
p=poly(rootsVec);
% initialize to empty vector
xVec=[];
for c=1:length(tVec)
%val=f(tVec(c));
t = tVec(c);
val = polyval(p,t)
% if functional value is not numerix
% convert to numeric
if isnumeric(val)==false
val=eval(val);
end
% add in Xvec vector
xVec=[xVec val];
end
% plot the graph
plot(tVec,xVec);
xlabel('t values');
ylabel('x(t) values');
title('x(t) vs t');
grid on

Respuestas (2)

Image Analyst
Image Analyst el 30 de Ag. de 2022
Editada: Image Analyst el 30 de Ag. de 2022
How are you calling it? For example are you doing this:
[tVec, xVec] = fxNthOrderPolysignal(1:10, [3,4,5,6]);
or some other way?
You're not just pushing the green run triangle are you? Because that will not send in input arguments to the function.

Chunru
Chunru el 30 de Ag. de 2022
% Call the function
[tVec,xVec]=fxNthOrderPolysignal([0 10], [1 2 3 2 1]);
% Define the function in the same file or separate file
function [tVec,xVec]=fxNthOrderPolysignal(domainVec, rootsVec)
% create time vector
tVec = linspace(domainVec(1),domainVec(2),100);
%obtain polynomial coefficients p from roots
p=poly(rootsVec);
% initialize to empty vector
xVec=[];
for c=1:length(tVec)
%val=f(tVec(c));
t = tVec(c);
val = polyval(p,t);
% if functional value is not numerix
% convert to numeric
if isnumeric(val)==false
val=eval(val);
end
% add in Xvec vector
xVec=[xVec val];
end
% plot the graph
plot(tVec,xVec);
xlabel('t values');
ylabel('x(t) values');
title('x(t) vs t');
grid on
end

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by