필터 지우기
필터 지우기

Why my variable is not defined in this scope?

조회 수: 7 (최근 30일)
Abdelrhman Abdelfatah
Abdelrhman Abdelfatah 2022년 12월 11일
답변: Dongyue 2022년 12월 15일
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
Stephen23
Stephen23 2022년 12월 11일
Check the value of L .
Abdelrhman Abdelfatah
Abdelrhman Abdelfatah 2022년 12월 11일
I put its value to be 4, and I calculated the dR and dR2 based on L value as following
m_kmax= max(m_k);
m_kmin= min(m_k);
stepsize=((m_kmax-m_kmin)/L);
if tread == 1
dR =linspace(m_kmin,m_kmax,L+1);
else
dR= stepsize + linspace(m_kmin,m_kmax,L+1);
end
dR2=zeros(1,L);
for i=1:L
dR2(i) = ( dR(i) + dR(i+1)) ./ 2;
end
But what I just figured is my function attached in this comment, which was supposeded to switch Quantizier between midrise or midtread is not actually doing what it was supposed to do, that's why I am considering adjusting it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Dongyue
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.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by