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

 채택된 답변

Stephen23
Stephen23 2018년 3월 26일
편집: Stephen23 2018년 3월 26일

0 개 추천

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.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Parallel Computing에 대해 자세히 알아보기

질문:

2018년 3월 26일

편집:

2018년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by