dct function throwing error using identity matrix as its parameter

3 次查看(过去 30 天)
I'm currently using MATLAB R2020a version in Windows 10.
So the problem occured when I used the exact same code I was using(and running without any errors) on MATLAB R2019a on mac computer.
When I run this line;
dct(eye(N))
it throws an error saying that some of the parameters might be missing or wrong.
I don't understand why this is happening since they are both built-in functions and I don't see in the release note any change about how 'dct' and 'eye' function's behavior changed.
I can assure you there was no attempt in making a local function called dct or eye.
What's the problem and how can I solve it? Thank you!
  3 个评论
Jong Sung Park
Jong Sung Park 2020-8-16
Thank you so much!!! How did I not think of that :(
Apparently, I was missing the signal processing toolbox, so didn't have a dct.
Though in my defense, other functions told me that I was missing a particular toolbox when I didn't have one. Error saying 'missing parameters' or 'wrong parameters' is totally misleading.
But again, thank you!
John D'Errico
John D'Errico 2020-8-16
Not all errrors are easy to catch. Software authors like me (as well as those who write code for the MathWorks) try to foresee every possible error someone might make. Then they check the inputs you provide when you use their code to see if you did something wrong in context of that function. If there is an issue, they will terminate the code while returning a descriptive error message. This moderately soft landing allows the user to resolve the problem as quickly as possible.
But sometimes you do something that was not expected. And I suppose if I was forced to test for too many possible mistakes, my code would itself become slow and inefficient. People will complain then too. So there is a limit, where an author won't necessarily test for every possible way someone might try to misuse the code. The code will simply continue processing, on now strange inputs. Something will now fail, in an unexpected, fairly arbitrary way. And then you will get some strange error message that makes relatively little sense to a new user. You may get what appears to you to be a "misleading" error message.
That is all part of using a complicated tool that you don't really understand at first. You move slowly and carefully, and try to avoid getting your fingers cut off.
It is difficult to know what exactly you did, because your statements about the exact errors were vague - i.e., once you did X, and you got a strange, misleading error message. Very often people create functions of their own with the name of an existing MATLAB function. Or you try to use a toolbox function for a toolbox you don't own. So one of the first questions you get in these cases is to have someone ask you to report the results of the which command, applied to the functions in the line you indicate.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by