how can i make this function work with arrays?
显示 更早的评论
i have this function which works great but whenever i input an array it says "matrix dimensions must agree"
function [f]=colebrook(R,k)
f=fzero(@(f) 1/sqrt(f)+2*log10(k/3.7+2.51/(R*sqrt(f))),[1e-18,1]);
end
what can i edit to make it work with arrays?
1 个评论
dpb
2021-6-10
Use the "dot" math operators for * and / for element-by-element operation instead of matrix.
See section on "Array vs Matrix Operations" in documentation or type
doc mtimes
doc rdivide
回答(1 个)
Sulaymon Eshkabilov
2021-6-10
Elementwise operation:
...
f=fzero(@(f) 1./sqrt(f)+2*log10(k/3.7+2.51./(R*sqrt(f))),[1e-18,1]);
...
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!