Changing the shape of functions defined by matrices

I have the following code in matlab

deltax=@(t)xt(t).'-xt(t);
deltay=@(t)yt(t).'-yt(t);
deltaz=@(t)zt(t).'-zt(t);

deltar=@(t)reshape([deltax(:) deltay(:) deltaz(:)].',3*(100+1),[]).';

where xt, yt, zt- all well-defined function on t. If I do deltax (2), I get an array of columns with 101 entries and similarly for deltay (2) and deltaz (2).

However, when I call

deltar(2)

I get this error

Input arguments to function include colon operator. To input the colon character, use ':' instead.

I also tried

deltar=@(t)reshape([deltax(t)(:) deltay(t)(:) deltaz(t)(:)].',3*(100+1),[]).';

but it gives me syntax errors.

I have to fulfill some basic error in matlab.

+4
source share
1 answer

deltax(t) , , - , ( MATLAB, ). reshape delta(x|y|z) :

deltar = @(t) reshape([reshape(deltax(t), [], 1) ...
                       reshape(deltay(t), [], 1) ...
                       reshape(deltaz(t), [], 1)].', 3*(100+1), []).';

, cat permute:

deltar = @(t) reshape(permute(cat(3, deltax(t), deltay(t), deltaz(t)), [3 1 2]), ...
                      3*(100+1), []).';

delta(x|y|z) 101--M, :

deltar = @(t) reshape([deltax(t).'; deltay(t).'; deltaz(t).'], [], 3*(100+1));
+6

Source: https://habr.com/ru/post/1690026/


All Articles