Assigning value to vector in based on conditional
古いコメントを表示
I'm trying to execute the following loop:
for m =1:length(r)
if imag(prelimsixmmrebar(m)) ~= 0
prelimsixmmrebar(m) = 4*2*Rc(m)*asin(r(m)/Rc(m))
end
end
with
r = 0.5:2.5;
h = (0.4/1.75)*r;
Rc = ((h.^2)+(r.^2))./(2.*h);
and
prelimsixmmrebar = ceil(180./acos((1.1^2)./(2*(r.^2)))).*2.*Rc.*asin(r./Rc)
If I understand correctly, the line inside the "if" statement should assign a new value only to the first element in prelimsixmmrebar, since this is the only one for which the boolean is true.
However, running the code reassigns new values to all of the elements. Using breakpoints to analyze, it seems that the reassignment is definitely happening at the line inside the "if" statement.
What am I missing? How would I reassign the value of the element - and only the value of that element in the vector prelimsixmmrebar?
Thanks in advance!!
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!