Why my variable is not defined in this scope?
5 次查看(过去 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
回答(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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!