Not enough input arguments error
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (2)
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.
0 comentarios
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
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!