I just need a quick and easy way to say The square root of xxxx is yyyyi so the square root of -100 is etc...
B = sqrt® ;
disp(B);
D = sprintf('R is negative. The square root of %1.1f is %1.1fi',R,B)
For some reason it says B is 0 for any number thats negative.

 Akzeptierte Antwort

Robert
Robert am 10 Mär. 2016

0 Stimmen

sprint is taking the real part of your complex result. Try:
sprintf('R is negative. The square root of %1.1f is %1.1fi',R,imag(B))

Weitere Antworten (0)

Kategorien

Mehr zu Function Creation finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 10 Mär. 2016

Beantwortet:

am 10 Mär. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by