function handle as array
2 views (last 30 days)
I define a function handle as
P = @(t) mtimes(expm(t.*M),P_initial);
Where P_initial is a 4x1 array and M a 4x4 matrix. This works fine, but now I have a function with for every t a 4x1 answer, for example at t = 0 I get:
What I want is to get this first element as a separate function of time, so I want a P_1(t) as a function handle, but I do not know how to do so.
Thanks already! :)
More Answers (1)
Davide Masiello on 2 Dec 2022
Edited: Davide Masiello on 2 Dec 2022
That's because mtimes(a,b) = a*b, and if a is 4x4 and b is 4x1 than the operation yields a 4x1 array.
I think what you might want to do is
P = @(t) expm(t.*M).*P_initial;
Which will yield a 4x4 matrix where each column is .
But I am not completely sure I interpreted this correctly.