How to only collect real part of the cube root

1 Ansicht (letzte 30 Tage)
Anil Kumar
Anil Kumar am 10 Jun. 2019
Kommentiert: Anil Kumar am 14 Jun. 2019
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

Akzeptierte Antwort

Steven Lord
Steven Lord am 10 Jun. 2019
Bearbeitet: Steven Lord am 10 Jun. 2019
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 Kommentar
Anil Kumar
Anil Kumar am 14 Jun. 2019
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Argument Definitions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by