Azzera filtri
Azzera filtri

Getting x value for a given y value from a fitted model

2 visualizzazioni (ultimi 30 giorni)
Here is my codes:
c=3*10^8; % speed of light
h=6.62606957*10.^-34; % Planck constant
k=1.3806488*10.^-23; % Boltzmann constant
T=(400:1:1000); % Temperatures in Kelvin
Wavelength=(0.925:0.001:0.975).*1e-6; %Wavelength from 0.925 to 0.975um
for i=1:601
I1(i,:)=(2*h*c*c)./((Wavelength.^5).*((exp((h.*c)./(k.*T(i).*Wavelength))-1)));
z(i) = trapz(Wavelength, I1(i,:));
end
Then the T and z are used to get a fitted curve
QQ截图20190309164625.png
I know it is easy to get z with z=fever(fittedmodel,T)
Is there any easy way to get T value from z value?
I tried to use z as xData and T as yData, but the fitting results are terrible. And I know I can use vpasolve to calculate z, but the errors in results is large because the coefficients is a range.
So, what can I do?

Risposta accettata

Star Strider
Star Strider il 9 Mar 2019
I am not certain that the curve fit is at all relevant to your finding a ‘T’ for a specific ‘z’.
Try this:
c=3*10^8; % speed of light
h=6.62606957*10.^-34; % Planck constant
k=1.3806488*10.^-23; % Boltzmann constant
T=(400:1:1000); % Temperatures in Kelvin
Wavelength=(0.925:0.001:0.975).*1e-6; %Wavelength from 0.925 to 0.975um
for i=1:601
I1(i,:)=(2*h*c*c)./((Wavelength.^5).*((exp((h.*c)./(k.*T(i).*Wavelength))-1)));
z(i) = trapz(Wavelength, I1(i,:));
end
zv = 2/3; % Desired ‘z’ Value
Tv = interp1(z, T, zv, 'linear'); % Associated ‘T’ Value
figure
plot(T, z)
hold on
plot(Tv, zv, '+r')
hold off
grid
xlabel('T')
ylabel('z')
Note that because ‘z’ is monotonically increasing with linearly increasing ‘T’, this approach is possible here. That is not allways the situation, so this approach would not be universally appropriate (for example if ‘z’ was periodic, parabolic, or something similar).
Experiment to get the result you want.

Più risposte (0)

Categorie

Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by