How do you separate the roots of a function?
Show older comments
For example, I wrote the following:
% a b c and d are input from the user
qx = [a b c d]; %a*x^3 + b*x^2 + c*x + d
derivative_qx = [3*a 2*b c]; %3*a*x^2 + 2*b*x + c
r = roots(derivative_qx);
disp(r);
If there are two roots how do I obtain the value of each separately so they are assigned to two different variables, such as r1 and r2. I was only able to find the roots function searching around, which displays both together.
Thanks
Accepted Answer
More Answers (1)
Andrei Bobrov
on 15 Oct 2014
qx = input('input as double array [1 x 4] = ');
dq = polyder(qx);
r = roots(dq);
use r(1) as r1 and r(2) as r2
1 Comment
Manoj
on 22 Apr 2018
% q1 %% Section 1a % Define crank length a=1;b=2;c=4;d=5;theta2=30; % Define input parameters and anonymous functions x1=120;xu=165;xi=120;xi_1=110;delta=0.01;precision=0.0001; f= % Student can choose one of these methods, all works % nr = newraph(f, df, xi, precision); % sc = secant(f, xi, xi_1, precision); % ms = modisecant(f, xi, pert, precision); % fzv = fzero(f, xi); % fzb = fzero(f, [xl, xu]);
%
%% Section 1b
% Define crank length
% Define input parameters for function
% Solve for root, for all ang2
% Plot the relation between the input angles and the output angles
%% Section 1C
%% Section 1D
% Write the result into text file
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!