norm of vector with cosine(var)

2 ビュー (過去 30 日間)
Arne Kähler
Arne Kähler 2021 年 2 月 20 日
回答済み: Arne Kähler 2021 年 2 月 21 日
How can I calculate the norm of a vector which is of form [sin(t);cos(t)]?
I tried
f=x*y^2;gamma=[2*cos(t);sin(t)];tmin=0;tmax=2*pi;
mod=matlabFunction(norm(dgamma))
value=int((fgamma)*mod,t,tmin,tmax)
with answer
mod =
function_handle with value:
@(t)sqrt(abs(cos(t)).^2+abs(sin(t)).^2.*4.0)
value = int(2*cos(t)*sin(t)^2*(abs(cos(t))^2 + 4*abs(sin(t))^2)^(1/2), t, 0, 2*pi)
  3 件のコメント
Arne Kähler
Arne Kähler 2021 年 2 月 21 日
That was an example @John D'Errico...
It's an unknown function handle put in by the user but my function had issues with calculating the euclidian Norm of a vector when theres cosine or sine in it, that's why I used the example.
I solved it by a simple workaround:
mod=0;
for k=1:nargin(f)
mod=mod+dgamma(k)^2;
end
mod=sqrt(mod);
integr=sym((fgamma)*mod)
value=int(integr,tmin,tmax)
John D'Errico
John D'Errico 2021 年 2 月 21 日
編集済み: John D'Errico 2021 年 2 月 21 日
Ok, so you have a more complex vector. I would note that what you claim you tried is meaningless, because it uses undefined variables, etc.
What is wrong with norm(V)?
And if that does not work, then what is wrong with sqrt(sum(V.^2))?
If you say you had problems, then you need to say WHAT problems, because what I've written does what you are asking. AND, you need to show code that actually does what you claim you tried.

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

採用された回答

Arne Kähler
Arne Kähler 2021 年 2 月 21 日
Thank you @John D'Errico that works as well.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by