The size of the indicated variable or array appears to be changing with each loop iteration. Commonly, this message appears because an array is growing by assignment or concat
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hosein Jeddi
am 19 Jul. 2021
Kommentiert: Stephen23
am 19 Jul. 2021
clc
clear
h = 1;
r = 0:h:20;
z = 0:h:20;
[rgrid,zgrid] = meshgrid(r,z);
zgrid = flip(zgrid);
b1=[];
for i=1:size(rgrid,1)*size(zgrid,2)
if zgrid(i) == min(min(zgrid))
b1 = [b1 i];
end
end
Akzeptierte Antwort
Stephen23
am 19 Jul. 2021
Bearbeitet: Stephen23
am 19 Jul. 2021
h = 1;
r = 0:h:20;
z = 0:h:20;
[rgrid,zgrid] = meshgrid(r,z);
zgrid = flip(zgrid)
Simpler, faster code:
b2 = find(zgrid==min(zgrid(:))).'
or even simply:
n3 = numel(z);
b3 = n3:n3:n3*numel(r)
Your code:
b1 = [];
for i = 1:size(rgrid,1)*size(zgrid,2)
if zgrid(i) == min(min(zgrid))
b1 = [b1 i];
end
end
b1
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!