diff and 3D-matrix

5 ビュー (過去 30 日間)
Bernd  Ab
Bernd Ab 2017 年 2 月 11 日
回答済み: Star Strider 2017 年 2 月 11 日
Dear all, I am reverse engineering a piece of the data evaluation code that is used in my university/ workgroup and i have a hard time understanding what seems to be a simple thing. I do understand what the output should be hover.The code is inside a loop but for now i just need to figure out what those two lines do in principle?
Fx(1:size(my_matrix,1)-1,i,j)=diff(my_matrix(:,i,j)/(a_scalar_dimension/1000));
Fx(size(my_matrix,1),i,j)=0;
Thank you very much in advance

回答 (1 件)

Star Strider
Star Strider 2017 年 2 月 11 日
The first assignment:
Fx(1:size(my_matrix,1)-1,i,j)=diff(my_matrix(:,i,j)/(a_scalar_dimension/1000));
simply seems to take the consecutive differences (using the diff funciton) over the rows of ‘my_matrix’ for the fixed second and third dimensions ‘i’ and ‘j’. We can assume this is in a nested loop of some design.
The second assignment:
Fx(size(my_matrix,1),i,j)=0;
sets the last element of ‘Fx’ for the same ‘i’ and ‘j’ coordinates to zero, apparently to equalise the row sizes of ‘Fx’ and ‘my_matrix’. In recent MATLAB versions, using end in place of the size call would have the same effect:
Fx(end+1,i,j)=0;
That’s my best guess, anyway.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by