How add condition statement in an array? - MATLAB -


i'm working on mapping linking 2 coordinates , database huge. hence display part of work on had done.

question: add start , stop number together. if more 1,000,000 distance 100. else distance remain unchanged. store in single array.

really appreciate respond. :)

coding

clear; n = xlsread('regionall.xlsx',2); m = xlsread('regionall.xlsx',1); % list of coordinates      distance  = distance(m(start,3:4), m(to,3:4)); % coordinates distancekm = deg2km(distance); sum = n(:,1)+n(:,2);  %problem below l = 1:625     sum = n(l,1)+n(l,2);     if (sum>1000000)         = 100;     else         = distancekm(l,1);     end; end 

excel data sample in variable n

start   stop    distance     13054   13055   0.017749628 13055   13001   0.152363674 560601  13043   0.063200318 560601  13042   0.036090789 560601  13041   0.021083981 560601  13037   0.04975146 560604  13031   0.047614849 560604  13030   0.051513765 560604  13029   0.076687991 560604  560605  0.060676069 560605  560606  0.046497332 

first sum columns 1 & 2, store result in summatrix:

summatrix = n(:,1) + n(:,2); 

then replace values > 1000000 in summatrix 100 using logical addressing:

summatrix(summatrix > 1000000) = 100; 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -