How to compute for the distance between two tensors using matlab?

조회 수: 3 (최근 30일)
Josephine Benjamin
Josephine Benjamin 2020년 8월 27일
답변: Dana 2020년 8월 27일
Consider two tensors X={(0 2;1 3), (1 4; 5 6)} and Y={(4 3; 2 1), (2 5; 6 2)}. I want to compute the distance between these two tensors in matlab. Can anyone help me make the matlab code of it. I am not that too familiar with matlab thanks

채택된 답변

Dana
Dana 2020년 8월 27일
It depends on how you define "distance". There are many different ways you could do that in principle. One way would be to use the element-wise p-norm: for a 3-D tensor A, this is given by and can be computed in MATLAB by norm(A(:),p). For example, for the 2-norm:
>> X=zeros(2,2,2);
>> X(:,:,1) = [0 2;1 3];
>> X(:,:,2) = [1 4; 5 6];
>> Y=zeros(2,2,2);
>> Y(:,:,1)= [4 3; 2 1];
>> Y(:,:,2) = [2 5; 6 2];
>> A = X-Y;
>> p = 2;
>> distance = norm(A(:),p)
distance =
6.4031

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dynamic System Models에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by