Find X value corresponding to Y value in a equation and find doesn't help as the y vector doesn't contain the exact value.

Hi everybody,
I am noob, so please help me out.
I am trying to find the beamwidth of a rectangular patch antenna. I have plotted the equations, but i have to find the value of x corresponding to the value at y=0.5. The function 'find' doesn't help as there is no exact value of y at 0.5. The result is a 1-by-0 empty matrix, which i guess is a null.
interp1 also doesn't help as I dont know the x-value.
So can you help me out?

Réponses (2)

You should be interpolating with y as the domain and x as the range
xi =interp1(y,x,0.5)
Sample function
x = 0:0.1:1;
y = x.^2;
Find approximative solution for y = 0.5
a = abs(y - 0.5);
ind = find(a == min(a));
Find exact solution with the approximative solution as starting value
fzero(@(x)(x^2 - 0.5), x(ind))

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by