Looping over a vector with non-integer values
显示 更早的评论
I'm trying to loop through each element of the vector 'N' but it keeps giving me back the 'attempting to access; index must be a positive integer or logical.' Is there a way I can do this without having to do each of them separately?
N = [15.66 9.27 6.72 4.84 4.1 3.4];
km_factors = zeros(size(N));
r = (616/2)/1000;
m = 1140;
vh = 1.999;
for i = N
x(i) = (0.3*i)/r;
z = m/vh;
km_factors = (2.73e-02*(x(i)))+(9.85e-04*(x(i)^2))-(5.71e-05*(z)) ...
+(8.22e-08*(z^2))-(2.87e-05*(x(i)*z));
end
disp(km_factors);
2 个评论
per isakson
2015-2-4
"do each of them separately?"   What do you mean? Do what separately?
Levi Autrey
2015-2-4
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!