When you substitute all variables at once in MATLAB using subs(y, [alpha, H, t], [15, 32, 50]), MATLAB might not handle the substitutions in the expected order, leading to an incorrect result.
However, when you substitute variables one by one, MATLAB updates the expression incrementally, ensuring that each substitution is correctly applied in sequence. This avoids any conflicts or misinterpretations that might occur when substituting multiple variables at once.
Ensuring Correct Substitution
To ensure correct substitution, you can continue using the step-by-step approach, which helps MATLAB correctly map each variable:
system = 1/(s + 1/alpha);
y = ilaplace(1/s * (1-exp(-s*H)) * system);
foo = subs(y, alpha, alpha_value);
foo = subs(foo, H, H_value);
foo = subs(foo, t, t_value);
disp('Result after step-by-step substitution:');
Result after step-by-step substitution:
Let's consider an example where the order of substitution can lead to different results.
Consider the expression: 
Now, let's substitute x = y + z, y = z + 1, and z = 2.
Substitution Order 1:
Substitute z = 2 => 
Substitute y = z + 1 => 
Substitute x = y + z => 
In this case, the expression becomes undefined due to division by zero.
Substitution Order 2:
Substitute x = y + z => 
Substitute y = z + 1 => 
Substitute z = 2 => 
In this case, the expression evaluates to 5.
The order of substitution can significantly affect the final result, especially in complex expressions where variables are interdependent. In the first order, the expression becomes undefined due to division by zero, while in the second order, the expression evaluates to a finite value.