Prompt the user to enter a vector of coefficients for the polynomial model. Verify that the entry has an even number of elements (an odd number of elements would mean an even order polynomial). If an invalid vector is entered, prompt the user to re-e

2 次查看(过去 30 天)
My code. I know how to prompt the user but I dont understand how to verify thier entry has even elements. I struggle on coding
n=1;
while n>=1
V(n)=(V(n-1)-(T(V(n-1))/(T(V(n-1))))); %the newton raphson
p=input('enter a vector of cofficients for an odd-order polynomial:');
n = length(p);
if n==3
V=p();
polyval(polyder(T),V(n))
elseif n==5
V=p();
polyval(p,V)
elseif n==7
V=p();
polyval(p,V)
else
warning('Adjust paremeters')
end
end

回答(1 个)

darova
darova 2019-10-6
Use mod() function
a = mod(b,a); % a=1 if b is odd

类别

Help CenterFile Exchange 中查找有关 Polynomials 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by