what exactly norm(x) function do?
古いコメントを表示
Good Afternoon,
I have to convert a part of my matlab code into C++.
I would be great if you can explain me what exactly norm(x) do on a vector of complex number so that I can write a C++ code for it.
I just asked a similar question on stack overflow but could not get much response.
Thank you in advance.
5 件のコメント
Manu Chaudhary
2022 年 9 月 21 日
移動済み: Adam Danz
2022 年 9 月 22 日
Steven Lord
2022 年 9 月 22 日
Are you performing the conversion to C++ manually or using MATLAB Coder? According to the Extended Capabilities section on its documentation page you can automatically generate C or C++ code from the norm function using MATLAB Coder.
Manu Chaudhary
2022 年 9 月 22 日
Manu Chaudhary
2022 年 9 月 22 日
編集済み: Manu Chaudhary
2022 年 9 月 22 日
採用された回答
その他の回答 (1 件)
Assuming you only care about p=2, If you already have code that computes norm(x) for real x, you can extend it to complex x via,
norm(x) = norm( [norm(real(x)), norm(imag(x)) ] )
which is easily verified below,
x=complex(rand(5,1), rand(5,1));
norm(x)
norm( [norm(real(x)), norm(imag(x)) ] )
Alternatively, if you have an implementation of abs, you could do norm(abs(x),p) which will work for any p-norm:
p=3;
norm(x,p)
norm(abs(x),p)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
