フィルターのクリア

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
  1 件のコメント
Soumili Sen
Soumili Sen 2021 年 3 月 13 日
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by