Effacer les filtres
Effacer les filtres

I have problem related to following code..plz help me..The error is "The variable 'mB' might be used before it is defined".

2 vues (au cours des 30 derniers jours)
function B1 = SortSignificanceFirst(B)
B1 = zeros(mB,1);
[mB, ~] = size(B);
SI = zeros(mB,2);
for b=1:mB
[mBB, ~] = size(B(b,1));
SI(b,:) = [mBB b];
end
SI_Sorted = sortrows(SI);
for b=1:mB
B1(b,1) = B(SI_Sorted(mB-b+1,2),1);
end

Réponses (1)

KSSV
KSSV le 11 Juil 2017
Check the code...your input in function is B and you are trying to initialize B1 using mB, at this line your function doesn't know what is mB; in the next line you are defining mB .So the error. You need to reverse the lines. First define mB and the use it.
function B1 = SortSignificanceFirst(B)
[mB, ~] = size(B);
B1 = zeros(mB,1);
SI = zeros(mB,2);
for b=1:mB
[mBB, ~] = size(B(b,1));
SI(b,:) = [mBB b];
end
SI_Sorted = sortrows(SI);
for b=1:mB
B1(b,1) = B(SI_Sorted(mB-b+1,2),1);
end

Catégories

En savoir plus sur Event Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by