MATLAB error: Output argument "variable" (and maybe others) not assigned during call to "function".
古いコメントを表示
Hi experts,
I am getting this error: Output argument "ci" (and maybe others) not assigned during call to "Query_last_process" with the following function. I am totally clueless why this is happening. I checked most of the posted answers on this type of errors, but the problem in those posted questions was that the output variable was not getting assigned any value, thus resulting in the error. What is annoying in my case is that I don't even want to return the value of "ci", then where from is this error of "not assigning" appearing. Any comments or suggestion from the community would be very helpful.
The code:
function [ph,lmat,bmat,pmetr,dec,nph] = Query_last_process(N,ph,lmat,bmat,ri,ci,pmetr,Ls,finx,nfinx,cply)
n = log2(N);
isf = ismember(ri,finx);
if (isf==1)
nph=2^ph;
for pva=1:nph
ltem1 = lmat(pva,ri,ci);
if (ltem1<0)
pmetr(pva)=pmetr(pva)+abs(ltem1);
end
end
else
ph=ph+1;
nph=2^ph;
if (nph<=Ls)
for pva=1:nph/2
lmat(nph/2 + pva,:,:) = lmat(pva,:,:);
bmat(nph/2 + pva,:,:) = bmat(pva,:,:);
bmat(pva,ri,ci)=0;
bmat(nph/2+pva,ri,ci)=1;
pmetr(pva + nph/2) = pmetr(pva);
if (lmat(pva,ri,ci) < 0)
pmetr(pva) = pmetr(pva) + abs(lmat(pva,ri,ci));
else
pmetr(pva + nph/2) = pmetr(pva + nph/2)...
+ abs(lmat(pva,ri,ci));
end
end
else
pmetr(Ls+1:2*Ls) = pmetr(1:Ls);
for it1=1:Ls
if (lmat(it1,ri,ci) < 0)
pmetr(it1) = pmetr(it1) + abs(lmat(it1,ri,ci));
else
pmetr(it1+Ls) = pmetr(it1) + abs(lmat(it1,ri,ci));
end
end
[sdm, sdp] = sort(pmetr);
for it1=1:Ls
if (sdp(it1) <= Ls)
bestL(it1,:,:) = lmat(sdp(it1),:,:);
bestB(it1,:,:) = bmat(sdp(it1),:,:);
bestB(it1,ri,ci) = 0;
else
bestL(it1,:,:) = lmat(sdp(it1)-Ls,:,:);
bestB(it1,:,:) = bmat(sdp(it1)-Ls,:,:);
bestB(it1,ri,ci) = 1;
end
end
lmat = bestL;
bmat = bestB;
pmetr = sdm;
ph=log2(Ls);
nph = 2^ph;
end
end
if(ri==N)
for it1=1:Ls
uht(it1,:) = bmat(it1,nfinx,n+1);
end
dec = dc_func(uht,cply); %dc_func is a function
end
end
2 件のコメント
James Tursa
2018 年 2 月 28 日
Please show the code line you are using to call this function.
Prakash
2018 年 2 月 28 日
回答 (1 件)
James Tursa
2018 年 2 月 28 日
編集済み: James Tursa
2018 年 2 月 28 日
It appears that the 5th output argument, dec, isn't always necessarily assigned by your function. It is only assigned if the condition ri==N is true. Could that be the variable that is not assigned for your call?
Also, what's the point of this for-loop at the end of your code?
for it1=1:Ls
uht(it1,:) = bmat(it1,nfinx,n+1);
end
Since uht is not an output variable, it is simply discarded when the function returns and the for-loop accomplished nothing.
3 件のコメント
James Tursa
2018 年 2 月 28 日
uht: Yes, you are right and I missed that.
ci: I don't see how the message you quote could be about ci since that is not an output argument. Let's see what you get after fixing up the dec stuff.
カテゴリ
ヘルプ センター および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!