MATLAB Answers

drawellipse not working, can't reproduce example

7 views (last 30 days)
I am trying to use the function drawellipse.
I have tried to reproduce the example with the Llama image in the help section but I get an error :
imshow(imread('llama.jpg'))
h = drawellipse('center',[50,50])
Undefined function 'cos' for input arguments of type 'char'.
Error in drawellipse (line 22)
[cos(elpar(o,3)) sin(elpar(o,3)); % rotate over phi
How could I be doing something wrong if I'm literally copying the example?

  0 Comments

Sign in to comment.

Accepted Answer

Sean de Wolski
Sean de Wolski on 23 Jan 2020
which -all drawellipse
Looks like you're shadowing this.

  3 Comments

Yahav Rave
Yahav Rave on 23 Jan 2020
Yes you were absolutely right, I had another function with the same name. Afterchanging that, the example now works.
Thanks all!
Image Analyst
Image Analyst on 23 Jan 2020
Strange. That may be. You may have had your own drawellipse() function, but why did it complain about the cos() function?
Sean de Wolski
Sean de Wolski on 27 Jan 2020
They were calling their drawellipse() function with the syntax MathWorks' one expects. So the inputs didn't line up and got propagated to cos().

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 23 Jan 2020
What does this show
>> which -all cos
You should see
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elfun\@double\cos) % double method
built-in (C:\Program Files\MATLAB\R2019b\toolbox\matlab\elfun\@single\cos) % single method
C:\Program Files\MATLAB\R2019b\toolbox\nnet\deep\@dlarray\cos.m % dlarray method
C:\Program Files\MATLAB\R2019b\toolbox\parallel\parallel\@codistributed\cos.m % codistributed method
C:\Program Files\MATLAB\R2019b\toolbox\parallel\gpu\@gpuArray\cos.m % gpuArray method
If you DON'T, then try this
> restoredefaultpath
and try the example again.

  3 Comments

Yahav Rave
Yahav Rave on 23 Jan 2020
>> which -all cos
built-in (C:\Program Files\MATLAB\R2019a\toolbox\matlab\elfun\@double\cos) % double method
built-in (C:\Program Files\MATLAB\R2019a\toolbox\matlab\elfun\@single\cos) % single method
C:\Program Files\MATLAB\R2019a\toolbox\symbolic\symbolic\@sym\cos.m % sym method
I get this response even after runing restoredefaultpath , and the example still fails with the same error.
Image Analyst
Image Analyst on 23 Jan 2020
It works for us. I just copied and pasted your code and it worked fine. As expected with no error. You should call tech support. You didn't assign cos to something in your script before you ran those lines, did you? Try putting that "which" in your script just before the call to drawellipse and see if there is an extra cos that shows up, like it would if you defined cos in your code somewhere. If not, call tech support and let us know how they resolved it.
Sean de Wolski
Sean de Wolski on 23 Jan 2020
Probably drawellpise itself, I doubt MW functionality would be algorithmic by line 22.

Sign in to comment.

Sign in to answer this question.

Products


Release

R2019a