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

 Akzeptierte Antwort

Stephen23
Stephen23 am 26 Mär. 2018
Bearbeitet: Stephen23 am 26 Mär. 2018

0 Stimmen

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.

Weitere Antworten (0)

Kategorien

Mehr zu Parallel Computing finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 26 Mär. 2018

Bearbeitet:

am 26 Mär. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by