Clear Filters
Clear Filters

when i want to get magnitude of vector in command window told me that index exceeds matrix dimensions. although i write true code

2 views (last 30 days)
v=[1 2 3 9 6]
v = 1x5
1 2 3 9 6
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
pp=v.^2
pp = 1x5
1 4 9 81 36
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Rr=sum(pp)
Rr = 131
mag=sqrt(Rr)
mag = 11.4455
disp(mag)
11.4455

Answers (1)

Paul
Paul on 11 May 2024
Code works here
v=[1 2 3 9 6]
v = 1x5
1 2 3 9 6
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
pp=v.^2
pp = 1x5
1 4 9 81 36
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Rr=sum(pp)
Rr = 131
mag=sqrt(Rr)
mag = 11.4455
disp(mag)
11.4455
Check
norm(v)
ans = 11.4455
Perhaps you have variable(s) named sum or sqrt or disp in your workspace?

Tags

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!