How can I vectorize this code that uses the fzero function?
古いコメントを表示
Hello,
I have the following code:
precision = 1000;
E = zeros(1,precision);
ecc = 0.3;
for k = 1:precision
M = 2*pi*k/precision;
E(k) = fzero(@(x) anomaly(x,M,ecc),M)
end
-----
function y = anomaly(x,M,ecc)
y = x - ecc*sin(x) - M;
end
Is there a way to vectorize this code and get rid of the k-loop? The fzero function doesn't accept a vector argument.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!