Azzera filtri
Azzera filtri

Not enough input arguments error

3 visualizzazioni (ultimi 30 giorni)
Riley Morris
Riley Morris il 30 Ago 2022
Risposto: Chunru il 30 Ago 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

Risposte (2)

Image Analyst
Image Analyst il 30 Ago 2022
Modificato: Image Analyst il 30 Ago 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 il 30 Ago 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

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by