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

1 visualizzazione (ultimi 30 giorni)
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

Risposte (1)

Paul
Paul il 11 Mag 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?

Categorie

Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange

Tag

Prodotti


Release

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by