How can I assign an empty value to a variable without getting the error "Unable to perform assignment because the left and right sides have a different number of elements."
Afficher commentaires plus anciens
MATLAB treats empty values as an empty vector. So, how can I avoid the afforementioned error in this case:
f = zeros(1,50);
for kk = 1: 50
[~, maxidx] = max(Mavg(:,:,kk));
f(kk) = find((Mavg(:,:,kk) <= ratio * N) & (maxidx <= 1:length(Mavg(:,:,kk))), 1 );
if isempty(f(kk))
f(kk) = 51;
end
end
1 commentaire
Waseem AL Aqqad
le 10 Déc 2021
Modifié(e) : Waseem AL Aqqad
le 10 Déc 2021
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 10 Déc 2021
You can't do that.
N = 50;
f = zeros(1,N);
for kk = 1: N
[~, maxidx] = max(Mavg(:,:,kk));
fkk = find(SOMETHING_NOT_CLEAR_WHAT);
if isempty(fkk)
fkk = N+1;
end
f(kk) = fkk;
end
1 commentaire
Waseem AL Aqqad
le 10 Déc 2021
Catégories
En savoir plus sur Fixed-Point Math Functions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!