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

 Réponse acceptée

Stephen23
Stephen23 le 26 Mar 2018
Modifié(e) : Stephen23 le 26 Mar 2018

0 votes

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.

Plus de réponses (0)

Catégories

En savoir plus sur Parallel Computing dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by