The question is to implement a function which computes the n

The question is to implement a function which computes the n region sign chart of polynomial by using matlab code. I thought this way at the bottom, but it doesn\'t run the program, can you please help me to find out the problem.
function [zs,ss]=signchart(f)
end
zs=unique(solve(f==0));
n=lenght(zs);
ss=zeros(1,n+1);
for i=1:length(zs)
if i==1
ss(1)=sign(f(zs(1)-0.001));
elseif i==n
ss(n)=sign(f(zs(n-1)+1));
  
else
ss(i)=sign(f(zs(i-1)+zs(i)/2));
end
end
end

The question is to implement a function which computes the n region sign chart of polynomial by using matlab code. I thought this way at the bottom, but it doesn\'t run the program, can you please help me to find out the problem.
function [zs,ss]=signchart(f)
end
zs=unique(solve(f==0));
n=lenght(zs);
ss=zeros(1,n+1);
for i=1:length(zs)
if i==1
ss(1)=sign(f(zs(1)-0.001));
elseif i==n
ss(n)=sign(f(zs(n-1)+1));
  
else
ss(i)=sign(f(zs(i-1)+zs(i)/2));
end
end
end

The question is to implement a function which computes the n region sign chart of polynomial by using matlab code. I thought this way at the bottom, but it doesn\'t run the program, can you please help me to find out the problem.
function [zs,ss]=signchart(f)
end
zs=unique(solve(f==0));
n=lenght(zs);
ss=zeros(1,n+1);
for i=1:length(zs)
if i==1
ss(1)=sign(f(zs(1)-0.001));
elseif i==n
ss(n)=sign(f(zs(n-1)+1));
  
else
ss(i)=sign(f(zs(i-1)+zs(i)/2));
end
end
end

Solution

You have written the end statement in the second line. This will mean to matlab that the function has ended there , hence throws an error. If you remove this, the program will run smoothly.

Also, there is an error in the spelling of length in the 4th line. Please correct the two.

function [zs,ss]=signchart(f)
  
zs=unique(solve(f==0));
n=length(zs);
ss=zeros(1,n+1);
for i=1:length(zs)
if i==1
ss(1)=sign(f(zs(1)-0.001));
elseif i==n
ss(n)=sign(f(zs(n-1)+1));
  
else
ss(i)=sign(f(zs(i-1)+zs(i)/2));
end
end
end

 The question is to implement a function which computes the n region sign chart of polynomial by using matlab code. I thought this way at the bottom, but it doe
 The question is to implement a function which computes the n region sign chart of polynomial by using matlab code. I thought this way at the bottom, but it doe

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site