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."
Show older comments
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 Comment
Waseem AL Aqqad
on 10 Dec 2021
Edited: Waseem AL Aqqad
on 10 Dec 2021
Accepted Answer
More Answers (1)
Walter Roberson
on 10 Dec 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 Comment
Waseem AL Aqqad
on 10 Dec 2021
Categories
Find more on Fixed-Point Math Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!