Borrar filtros
Borrar filtros

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 visualizaciones (últimos 30 días)
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

Respuestas (1)

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

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by