Negative squareroot quick and easy
조회 수: 7 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Robert
2016년 3월 10일
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))
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!