[英]How to read a table in matlab, find the y values corresponding to x
I want to use the y
value corresponding to the given x
value from the table (my current table has 1000 values with 10-4 decimal points so I use : 我想使用与表中给定x
值相对应的y
值(我的当前表具有1000个值,带有10-4个小数点,因此我使用:
load question_table.mat
eta_p = %assign a value
F12_p=find( (eta <eta_p+0.01) & (eta > eta_p-0.01), 1, 'first' )
what is missing ? 什么东西少了 ?
Here is how I have created the table, run this program. 这是我创建表的方式,运行此程序。
i = 1;
etaspan = -500:0.001:500;
y = zeros(length(etaspan),1);
f = @(x,eta) (x.^(1/2))./(1+exp(x-eta));
for eta = etaspan
g = @(x) f(x,eta);
y(i) = integral(g,0,500);
i = i + 1;
end
f=y
eta=etaspan
save question_table.mat eta f
Just have MATLAB do the interpolation for you: 只需让MATLAB为您完成插值即可:
y_p = interp1(eta, y, eta_p);
interp1
uses linear interpolation by default, but can instead use higher order interpolation methods. 默认情况下, interp1
使用线性插值,但可以使用高阶插值方法。 Even with linear, your table seems much denser than necessary. 即使使用线性,您的表似乎也比所需的密度大得多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.