필터 지우기
필터 지우기

How to only collect real part of the cube root

조회 수: 1 (최근 30일)
Anil Kumar
Anil Kumar 2019년 6월 10일
댓글: Anil Kumar 2019년 6월 14일
I am having a problem while calculating the cube root in the following code; I am getting an imaginary value of R0, which is not physically possible for the problem! how do I could get the real part only in this problem? please help!
N=50
R= linspace(30e-9,100e-9,N)
Nt= linspace(1e17,1e18,N)
Nd= 5e24
for i= N
R0(i) =((3*R(i).^2).*(-(Nt(i)./Nd)+(R(i)./3))).^(1/3)
end

채택된 답변

Steven Lord
Steven Lord 2019년 6월 10일
편집: Steven Lord 2019년 6월 10일
Use the nthroot function. With this you can replace your loop with element-wise operators and process your whole vector of data in one nthroot call.
  댓글 수: 1
Anil Kumar
Anil Kumar 2019년 6월 14일
Thank You steven! i tried your suggestion but could not implement this.Can you demosntrate this fucntion in the above mentioned code? how to use it? Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Argument Definitions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by