Your task is to implement a function which computes 3region
Your task is to implement a function which computes 3-region sign chart, given a polynomial.
Using Matlab, create a function with signature function [zs ss] = signchart(f).
The f input to signchart will be a symbolic polynomial (see below).
The zs output is a column vector of the unique zeros of the f.
The ss output is a column vector of the signs in regions. For example, if the sign pattern is --+ then ss == [-1; -1; 1].
Here is an example of how f will be constructed.
Hints
The solve will return solutions according to their multiplicity. The function length will tell you the number of elements in a vector. You may find the function unique useful. You can see how to use the functions:
Solution
function [zs ss] = signchart(f)
 syms x
 f = x^2+2*x+1;
 zs1 = solve(f==0);
 zs = unique(zs1)
 tol = 0.001;
 for i = 1:length(zs)
 x = (zs(i)-tol);
 y = subs(f);
 if y < 0
 ss(i) = -1;
 else
 ss(i) = 1;
 end
 end
 fprintf(\'OUTPUT ss: %d\\t\',ss);
 %fprintf(\'OUTPUT zs: %d\\t\',zs);
 end
![Your task is to implement a function which computes 3-region sign chart, given a polynomial. Using Matlab, create a function with signature function [zs ss] = s Your task is to implement a function which computes 3-region sign chart, given a polynomial. Using Matlab, create a function with signature function [zs ss] = s](/WebImages/11/your-task-is-to-implement-a-function-which-computes-3region-1007293-1761519427-0.webp)
