Azzera filtri
Azzera filtri

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 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

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

Categorie

Scopri di più su Polynomials in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by