필터 지우기
필터 지우기

How to write ||a-p||^2 in matlab code

조회 수: 1 (최근 30일)
Soumili Sen
Soumili Sen 2021년 3월 12일
댓글: Soumili Sen 2021년 3월 13일
Hello all,
I have two variables 'a' and 'p Now I want to express this expression as
f=||a-p||^2;
What will be the matlab code for this expression?
  댓글 수: 2
KSSV
KSSV 2021년 3월 12일
Read about norm
Soumili Sen
Soumili Sen 2021년 3월 13일

댓글을 달려면 로그인하십시오.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2021년 3월 12일
Have a look at the norm function and its help and documentation. If your a and p are  [n x m] arrays and you want to get ||a-p||^2 for each row you might do something like this:
n_ap = sum((a-p).^2,2);
adapt to handle complex values if necessary.
HTH

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by