MATLAB Answers

dct function throwing error using identity matrix as its parameter

2 views (last 30 days)
Jong Sung Park
Jong Sung Park on 16 Aug 2020
Commented: John D'Errico on 16 Aug 2020
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 Comments

Walter Roberson
Walter Roberson on 16 Aug 2020
What shows up for
which eye
which dct
You should see toolbox/matlab/elmat/eye and toolbox/signal/signal/dct.m
Jong Sung Park
Jong Sung Park on 16 Aug 2020
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 on 16 Aug 2020
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.

Sign in to comment.

Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by