定义函数
fun3
function [f] = fun3(v,a,ri,ro)
f=v.^3.*integral(@(r)(exp(v.*(r.^a))-1).^(-1).*r,ri,ro);
end这个定义函数直接带入变量可出来结果,但是我用plot做图就出错了,代码如下:
v=0:0.01:500;
plot(v,fun3(v,1,1,100));
错误显示为Matrix dimensions must agree.
请问究竟是什么哪里出了问题?不知道哪位能帮我看看,谢谢了。

 Réponse acceptée

0 votes

你这个对每个v求得一个积分,所以fun3应该改一下a:
function [f] = fun3(v,a,ri,ro)
f=v.^3.*arrayfun(@(v)integral(@(r)(exp(v*(r.^a))-1).^(-1).*r,ri,ro),v);
end
v的间隔不要取太小,v = 0:0.5:500就行

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!