Not enough input arguments error
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Image Analyst
2022년 8월 30일
편집: Image Analyst
2022년 8월 30일
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
Chunru
2022년 8월 30일
% 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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!