Finding zeros and intersections

Versione 1.0.0.0 (1,34 KB) da Patrick
With data (x,y), the function finds "x" that correspond to y=y0.
830 download
Aggiornato 3 dic 2009

Visualizza la licenza

xsol=fzero_data(x,y,y0);
"fzero.m" function (Optim toolbox) computes one zero of a defined one-variable function, while "fzero_data.m" computes all the zeros (or crossings) of data vectors x and y at y=y0. The number of solutions can be found with "length(xsol)". If the requested value y=y0 is not in the range of the data, an error will stop the program. For better accuracy the function "spline()" instead of "interp1()" can be inserted in the last loop of the function.

%%%%%%%%%% example %%%%%%%%%

theta=0:0.01:2*pi;
f=sin(2.*theta);

%find the solutions for f=0
f0=0;
theta0=fzero_data(theta,f,f0);
Nsol0=length(theta0);

%find the solutions for f=0.95
f1=0.95;
theta1=fzero_data(theta,f,f1);
Nsol1=length(theta1);

plot(theta,f,'-k',[0,theta0],f0.*ones(1,Nsol0+1),'-*r',[0,theta1],f1.*ones(1,Nsol1+1),'-ob')
%%%%%%%%%%%%%%%%%%%%%%%%%%

Cita come

Patrick (2025). Finding zeros and intersections (https://it.mathworks.com/matlabcentral/fileexchange/26014-finding-zeros-and-intersections), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2008b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Versione Pubblicato Note della release
1.0.0.0