Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a range of vectors which are P1,P2,P3 and I would like to write and if statement that if a certain vector is selected a corresponding matrix is selected.

for example if the user puts into the function P1 the corresponding output WP1 will be selected.

What I have tried:

WP1= [2.47 1.93 0;
11.68 2.11 0.01;
18.64 2.2 0.01;
24.87 2.29 0.01;
34.5 2.1 0];


WP2= [1.57 -1.78 0.01;
12.3 -1.5 0;
19.4 -1.3 0;
29.4 -1 0;
35.8 -1.3 0;
40.1 -3.1 0];


WP3= [2.02 1.75 0;
17.3 1.6 0;
27.2 1.1 0;
35.3 1.6 0;
38.2 3.3 0];


P1=[2.47 1.93 0];
P2=[1.57 -1.78 0.01];
P3=[2.02 1.75 0];

P=[P1;P2;P3]
WP=[WP1;WP2;WP3]

if P == P1
WP= WP1;
end
elseif P == Position2
WP= WP2;
elseif P == Position3
WP= WP3;
end


values = input(P1,WP) %% WP needs to be selected automatically based on the choice of P
Posted
Updated 31-Mar-21 23:17pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900