Hello, I am trying to assign a new matrix with values according to the inputs of two other matrices, see script below. However, vector Distance is not created at all. Could somebody please help?
Thanks.
clear
close all
clc
Revealeddummyfinal_all = importdata('Revealed_dummy_final.xlsx');
Revealeddummyfinal = Revealeddummyfinal_all.data;
Entrance = Revealeddummyfinal(:,6);
CHOICE = Revealeddummyfinal(:,14);
for i = 1:229
if Entrance(i) == 1
if CHOICE(i) == (511 || 512)
Distance(i) = 30;
elseif CHOICE(i) == (521 || 522)
Distance(i) = 40;
elseif CHOICE(i) == (611 || 612)
Distance(i) = 40;
elseif CHOICE(i) == (621 || 622)
Distance(i) = 50;
elseif CHOICE(i) == (711 || 712)
Distance(i) = 50;
elseif CHOICE(i) == (721 || 722)
Distance(i) = 60;
end
elseif Entrance(i) == 2
if CHOICE(i) == (511 || 512)
Distance(i) = 60;
elseif CHOICE(i) == (521 || 522)
Distance(i) = 50;
elseif CHOICE(i) == (611 || 612)
Distance(i) = 50;
elseif CHOICE(i) == (621 || 622)
Distance(i) = 40;
elseif CHOICE(i) == (711 || 712)
Distance(i) = 40;
elseif CHOICE(i) == (721 || 722)
Distance(i) = 30;
end
end
end

 Accepted Answer

Stephen23
Stephen23 on 26 Mar 2018
Edited: Stephen23 on 26 Mar 2018
Instead of this:
CHOICE(i) == (511 || 512)
you need this:
CHOICE(i)==511 || CHOICE(i)==512
Following the rules for operator precedence what you wrote is equivalent to:
CHOICE(i) == (511 || 512)
CHOICE(i) == True
which is likely to be False unless that value of CHOICE is 1 or True.

More Answers (0)

Categories

Find more on Parallel Computing in Help Center and File Exchange

Asked:

on 26 Mar 2018

Edited:

on 26 Mar 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!