NaN issue and if statement
I’m having trouble with my code when I add an if condition to check if B_body(3) is less than 1e-5.
Without the if condition, everything works fine.
But when I add the if condition, I get a warning and B_body(3) values become NaN.
I’ve tried several solutions, but nothing works.
Any ideas on how to fix this?
epsilon=1e-5;
if abs(B_body(3))<epsilon
T_rw=[0;0;0];
else
T_rw = [0; 0; 1] * (B_body’ * T_commanded) / (B_body(3));
endI’m having trouble with my code when I add an if condition to check if B_body(3) is less than 1e-5.
Without the if condition, everything works fine.
But when I add the if condition, I get a warning and B_body(3) values become NaN.
I’ve tried several solutions, but nothing works.
Any ideas on how to fix this?
epsilon=1e-5;
if abs(B_body(3))<epsilon
T_rw=[0;0;0];
else
T_rw = [0; 0; 1] * (B_body’ * T_commanded) / (B_body(3));
end I’m having trouble with my code when I add an if condition to check if B_body(3) is less than 1e-5.
Without the if condition, everything works fine.
But when I add the if condition, I get a warning and B_body(3) values become NaN.
I’ve tried several solutions, but nothing works.
Any ideas on how to fix this?
epsilon=1e-5;
if abs(B_body(3))<epsilon
T_rw=[0;0;0];
else
T_rw = [0; 0; 1] * (B_body’ * T_commanded) / (B_body(3));
end nan MATLAB Answers — New Questions