필터 지우기
필터 지우기

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