Why did I get this error?

조회 수: 6 (최근 30일)
Ender Rencuzogullari
Ender Rencuzogullari 2016년 3월 8일
댓글: Steven Lord 2016년 3월 8일
I have completed my program about three months ago and it was working perfectly. My laptop was broken one month ago, so I have loaded Matlab R2013a again. Today, I got this error:
Undefined function 'deg2rad' for input arguments of type 'double'
Related line is:
rb = rp*cos(deg2rad(pre_ang));
where pre_ang is an input value, rb and rp are calculated by program.
Why is this happening now although it was not a problem before?
Thanks to contributers.

답변 (1개)

Ken Atwell
Ken Atwell 2016년 3월 8일
The function deg2rag was introduced in R2015b, according to the documentation. Could you have previously been using a newer version of MATLAB? Or, maybe you had downloaded a File Exchange contribution like this one?
  댓글 수: 2
Ender Rencuzogullari
Ender Rencuzogullari 2016년 3월 8일
Calling categorical is a data conversion, so
c = categorical([12 12 13])
completely throws away the numeric values. In general, there is no way to get them back unless you have saved them, any more than you can get back the original values from int8([1.1 2.2 3.3]). Calling categorical is a data conversion.
That being said, you can certainly save the unique numeric values, and then index into those using the categorical array:
n = uniqueNumericValues(c)
You can also call double on a categorical, but what you will get back are the category numbers, not the original numeric values.
But here's the question: if you need to convert back to the original numbers, and you are not using meaningful category names when converting from those numbers, why use categorical to begin with? There may be things you haven't mentioned.
Steven Lord
Steven Lord 2016년 3월 8일
DEG2RAD existed in Mapping Toolbox before it was moved into MATLAB in release R2015b (as documented in the Release Notes for Mapping Toolbox and for MATLAB for that release.) You probably had that toolbox installed before your laptop broke, or you had written your own version of that function.

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

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by