0

I'm working on a mapping by linking 2 coordinates together and my database is huge. Hence I only display part of the work on what I had done.

Question: I would like to add the start and stop number together. If it is more than 1,000,000 the distance will be 100. Else the distance will remain unchanged. Then I would like it to store it in a single array.

Really appreciate your respond. Thanks :)

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 a below
for l = 1:625
    sum = N(l,1)+N(l,2);
    if (sum>1000000)
        a = 100;
    else
        a = 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

1 Answer 1

1

First sum columns 1 & 2, store the result in SumMatrix:

SumMatrix = N(:,1) + N(:,2);

Then replace all values > 1000000 in SumMatrix with 100 by using logical addressing:

SumMatrix(SumMatrix > 1000000) = 100;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.