matlab中不能直接求任意底数的对数对吧

大海jianfei
2011-05-02 · TA获得超过628个赞
知道小有建树答主
回答量:215
采纳率:0%
帮助的人:258万
展开全部
不能但能计算E,2 ,10为底数的对数 其他的用那个间接计算么
function y=logn(x,n)
if x==0 | n==0
disp('warning:log of zero!');
y=NaN;
elseif n==1
disp('error:n==1');
else
if x<0 | n<0
disp('warning:the result will be imaginary!');
end
switch n
case exp(1)
y=log(x);
case 2
y=log2(x);
case 10
y=log10(x);
otherwise
y=log(x)/log(n);
end
end
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式