Why my variable is not defined in this scope?
조회 수: 7 (최근 30일)
이전 댓글 표시
I have the following function
dq_k = [];
for i1 = 1:numel(d_k)
if (d_k(i1) <= dR(end) && d_k(i1) >= dR(end-1)) % greater than or equal to maximum interval
dqe1 = dR2(end); % use maximum interval value
else
for i2 = 1:L-1
if (d_k(i1) <= dR(end-i2)) && (d_k(i1) >= dR(end-i2-1))
dqe1 = dR2(end-i2);
end
end
end
dq_k = [dq_k dqe1];
end
everytime I run it inside my whole code
it gives me this error
Unrecognized function or variable 'dqe1'.
Error in Trial2222 (line 63)
dq_k = [dq_k dqe1];
And here are my input varaibles to this function
dR =
1.0000 2.5000 4.0000 5.5000 7.0000
dR2 =
1.7500 3.2500 4.7500 6.2500
d_k =
1.0000 1.0000 0.2500 -0.5000 -1.2500 -2.0000 -2.7500
댓글 수: 2
답변 (1개)
Dongyue
2022년 12월 15일
If the two conditions:
if (d_k(i1) <= dR(end) && d_k(i1) >= dR(end-1))
and
if (d_k(i1) <= dR(end-i2)) && (d_k(i1) >= dR(end-i2-1))
are both not met, dqe1 will not be created unless you set default value for it.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!