Only the first if-statement block executes,
Hi there!
I wrote an if-statement, followed by an if-else statement, followed by another if-else statement, followed by the end keyword.
The goal is to use different formulas for different values of alpha, something like the below.
However, it seems that only the first if-statement block executes — for all possible values of alpha, even when alpha already exceeds that interval.
Where is my mistake? Thanks in advance.
alpha = linspace(0,3*pi/2,1000)
if 0 <= alpha <= pi/2
vx = …;
vy = …;
elseif pi/2 < alpha <= pi
vx = …;
vy = …;
elseif pi < alpha <= 3*pi/2
vx = …;
vy = …;
endHi there!
I wrote an if-statement, followed by an if-else statement, followed by another if-else statement, followed by the end keyword.
The goal is to use different formulas for different values of alpha, something like the below.
However, it seems that only the first if-statement block executes — for all possible values of alpha, even when alpha already exceeds that interval.
Where is my mistake? Thanks in advance.
alpha = linspace(0,3*pi/2,1000)
if 0 <= alpha <= pi/2
vx = …;
vy = …;
elseif pi/2 < alpha <= pi
vx = …;
vy = …;
elseif pi < alpha <= 3*pi/2
vx = …;
vy = …;
end Hi there!
I wrote an if-statement, followed by an if-else statement, followed by another if-else statement, followed by the end keyword.
The goal is to use different formulas for different values of alpha, something like the below.
However, it seems that only the first if-statement block executes — for all possible values of alpha, even when alpha already exceeds that interval.
Where is my mistake? Thanks in advance.
alpha = linspace(0,3*pi/2,1000)
if 0 <= alpha <= pi/2
vx = …;
vy = …;
elseif pi/2 < alpha <= pi
vx = …;
vy = …;
elseif pi < alpha <= 3*pi/2
vx = …;
vy = …;
end if statement MATLAB Answers — New Questions