Getting x value for a given y value from a fitted model
조회 수: 2 (최근 30일)
이전 댓글 표시
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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207646/QQ%E6%88%AA%E5%9B%BE20190309164625.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?
댓글 수: 0
채택된 답변
Star Strider
2019년 3월 9일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!