I have an If statement I need to carry out where the result should be a single number for each time the if is executed. What I have at the moment returns a list for each time the If is executed. I specifically do not want to use a Do loop so is there a way to use Map to do this?
x = {0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`};
y = {0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`, 0.897409001634915`,
0.897409001634915`, 0.897409001634915`};
z = {0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
TimeModelSelection[41]
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
The first few lines of the result are
Map[If[# == 0, x*y, z] &, TimeModelSelection[41], {1}]
{{0.8053429162, 0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162, 0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162, 0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162, 0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162}, {0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162, 0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162, 0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162, 0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162, 0.8053429162, 0.8053429162, 0.8053429162,
0.8053429162},...
I have also tried thefollowing without luck
Map[If[# == 0, x[[#]]*y[[#]], z[[#]]] &, TimeModelSelection[41], {1}]