Effacer les filtres
Effacer les filtres

sqrt of elements of a vector

17 vues (au cours des 30 derniers jours)
dav
dav le 19 Fév 2013
Hi
I have a vector of five elements
I need to calculate the sqrt of each element and put it in anoter vector. How can I do this:
What I have V = [ 4 9 49 25 100]
What I want A = [2 3 7 5 10]
It is better to know how to do this in a "for" loop too.
Thanks

Réponse acceptée

the cyclist
the cyclist le 19 Fév 2013

Plus de réponses (1)

Youssef  Khmou
Youssef Khmou le 19 Fév 2013
hi,
Using a loop :
for x=1:length(V)
% A(x)=sqrt(V(x));
A(x)=V(x)^0.5;
end
Alternative sol :
A=V.^0.5;
  1 commentaire
dav
dav le 21 Fév 2013
thanks

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by