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에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!