Why do I get error for integral
古いコメントを表示
Hello,
I'm quite a matlab dummy and it would be nice, if you could help me with this.
When integrating the following function I get the error "Array indices must be positive integers or logical values.". I think it's about the "f(x)-u_equ(x))" term, which is negative. But as the formula is like this I don't know what to do. Sorry in advance if the question/solution is trivial.
clear all;
n=1;
t1 = 14;
t2 = 25;
len = 20; %length of model
initemp = 10; %initial temperature
steps = 20;
u_equ=zeros(1,steps);
f=zeros(1,steps);
% equilibrium temperature
for x=1:steps
u_equ(x) = t1+((t2-t1)/len).*x;
f(x) = initemp;
end
fun = @(x) (f(x)-u_equ(x)).*sin((n.*pi.*x)/len); %function to integrate
intgr = integral(fun,0,len)
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Operating on Diagonal Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!