필터 지우기
필터 지우기

sqrt of elements of a vector

조회 수: 17 (최근 30일)
dav
dav 2013년 2월 19일
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

채택된 답변

the cyclist
the cyclist 2013년 2월 19일

추가 답변 (1개)

Youssef  Khmou
Youssef Khmou 2013년 2월 19일
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;

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by