All my points are not showing up after for-loop
古いコメントを表示
I have three matrixes. One with x values, one for y values and a last for mass. Where the mass in point (1,1) is located in the location given by x(1,1) and y(1,1).
I am trying to create a new matrix showing the mass combined in a map grid.
[xi,yi] = meshgrid(300:0.25:380,0:0.25:90);
B = zeros(size(yi,1),size(xi,2));
for i = 1: size(xi,2)
for j = 1: length(yi)
m = find((x<(xi(1,i)+0.1250)) & (x>(xi(1,i))-0.1250));
n = find((y<(yi(j,1))+0.1250) & (y>(yi(j,1))-0.1250));
if length(m)<=length(n)
for k = 1:length(m)
if m(k) == n(k)
B(j,i) = B(j,i) + bmass(m(k));
end
end
end
if length(m) > length(n)
for k = 1: length(n)
if n(k) == m(k)
B(j,i) = B(j,i) + bmass(n(k));
end
end
end
end
end
when finished my new matrix B only contains 170 points which are non-zero. I know that in my bmass variable has over 60'000 values, and all should be located in the region of interest.
Thanks for any advice to how to improve code (new to matlab, so any comments on how to improve is welcome)
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!