Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
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

Réponses (1)

Paul
Paul le 11 Mai 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

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by