The question is to implement a function which computes the n region sign chart o
ID: 3774205 • Letter: T
Question
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 endThe 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
Explanation / Answer
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
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.