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

3 views (last 30 days)
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

Answers (1)

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

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!