在MATLAB中计算函数的逆函数 [英] Computing the inverse of function in MATLAB
本文介绍了在MATLAB中计算函数的逆函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在MATLAB中计算函数的逆函数?假设您要计算f(x)= e ^ x的逆,那么代码是什么?
How do you compute the inverse of a function in MATLAB? Say you want to compute the inverse of f(x)=e^x, what would be the code?
推荐答案
如果分析方法失败(在可能的情况下首选),请使用数值方法:
If the analytical approach fails (which is preferred whenever possible) use numerical approach:
给出y并求出x0的倒数
Given y and guess x0 for the inverse
x = fzero( @(x)(f(x)-y), x0 );
或者当x的范围已知为xmin ... xmax时使用低精度但较快的方法
or a low accuracy but faster method when the range of x known to be bounded in xmin...xmax
xx = linspace( xmin, xmax, N );
yy = f(xx);
x = interp1(yy, xx, y);
当然,必须根据所需的精度选择N.
Of course, N has to be chosen according to the desired accuracy.
这篇关于在MATLAB中计算函数的逆函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文