Effacer les filtres
Effacer les filtres

how i can know the roots

1 vue (au cours des 30 derniers jours)
yasmeen hadadd
yasmeen hadadd le 24 Août 2016
Commenté : yasmeen hadadd le 24 Août 2016
Hello;
i have a curve without his function , how i can know the roots( intersection with x-axis , y=0), using for loop thanks

Réponse acceptée

KSSV
KSSV le 24 Août 2016
Multiple ways are there..
1. Fit a polynomial for the data and get the intersection points with x and y axes.
2. Use interpolation.
Eg:
clc; clear all ;
c = @(x) x.^3+x.^2-x-1 ;
N = 100 ;
x = linspace(-4,4,1000) ;
y = c(x) ;
plot(x,y) ; grid on ; hold on
% Get intersection with x-axes (y = 0)
x0 = interp1(y,x,0) ;
plot(x0,0,'*r')
% Get intersection with y-axes (x = 0)
y0 = interp1(x,y,0) ;
plot(0,y0,'*b')
In the above code, I have used inbuilt interpolation...you may write your code using for loops...
  1 commentaire
yasmeen hadadd
yasmeen hadadd le 24 Août 2016
thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by