calculation x-value, given the y-value of a discrete function

8 visualizaciones (últimos 30 días)
marie deseyn
marie deseyn el 18 de Feb. de 2020
Respondida: KSSV el 18 de Feb. de 2020
I want to calculate the x-value of a given function in a given y, but my function is only available in discrete points how can I do that?
This is the function I made to make the function, what I basicly want to do is finding the x-value where 'plot(squeeze(chi2(1:20,15,10)))' intersects with minchi.
Thanks in advance
C=10;
x0=15;
a=9;
xen =linspace(0,60);
%adding noise
xen =linspace(0,60,100)';
y= C./ sqrt((xen.^2-x0^2).^2+a*xen.^2);
naruisy = y + randn(100,1)*0.01;%amplitude = *0.04
plot(xen,y)
hold on
plot(xen,naruisy)
chi2 = zeros(20,20,20);
minchi2 = 100;
for a = linspace(1,20,20)
for b = linspace(1,20,20)
%fprintf('huidige index:%i\n', b)
for c = linspace(1,20,20)
somelementen = [];
ymetparam = c./ sqrt((xen.^2-b^2).^2+a*xen.^2);
somelementen = (naruisy- ymetparam).^2;
% plot(xen,naruisy)
% hold on
% plot(xen,ymetparam,'g')
% hold off
% pause(0.2)
chi2(a,b,c)=sum(somelementen)/(length(somelementen)-3);
if chi2(a,b,c) < minchi2
minchi2 = chi2(a,b,c);
minparam = [a,b,c];
%minchi2
end
end
end
end
plot(squeeze(chi2(9,15,1:20)))
hold on
minchi2
xplot=linspace(0,20,100);
yplot=xplot-xplot + minchi2;
plot(xplot,yplot)
hold on
yplot=xplot-xplot + 2*minchi2;
hold on
plot(xplot,yplot)
%%
%bij c_best en b_best de a bekijken
plot(squeeze(chi2(1:20,15,10)))
hold on
minchi2
xplot=linspace(0,20,100);
yplot=xplot-xplot + minchi2;
plot(xplot,yplot)
hold on
yplot=xplot-xplot + 2*minchi2;
hold on
plot(xplot,yplot)

Respuestas (1)

KSSV
KSSV el 18 de Feb. de 2020
Read about interp1, knnsearch.

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by