I'm getting following error: Array indices must be positive integers or logical values.
16 ビュー (過去 30 日間)
古いコメントを表示
Hi, when I test following code whit some easy nubers I get the error: Array indices must be positive integers or logical values. (in the line I(0) = b - a) I already tried clearing the workspace but the same error keeps popping up. What else could be the problem?
function [H] = ComputeWeights(a,b,x)
n = length(x)-1;
I = ones(n+1);
I(0) = b - a;
I(1) = 0;
for i = 2:n+1
I(i) = ((b-a)*((-1)^i + 1))/(2*(1-i^2));
end
for i = 0:n+1
x(i) = ((2/(b-a))*(x-a))-1;
end
T = zeros(n+1,n+1);
for i = 0:n+1
for k = 0:n+1
T(i,k) = cos(k*acos(x(i)));
end
end
H = linsolve(T,transpose(I));
end
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!