Amrmsmb
Amrmsmb

Reputation: 11416

"Unexpected MATLAB operator" error when reading image

I am trying to read an image in Matlab using the following command as I found it in Matlab docs:

A = imread(d:/img,png)

but the problem is Matlab can not read the path and says : Error: Unexpected MATLAB operator.

I also tried using, /, //, \ and \ in the filepath, but none of them worked.

Please let me know how to get it working.

Upvotes: 0

Views: 190

Answers (2)

NKN
NKN

Reputation: 6434

Also there is difference in the platforms:

  • path on Microsoft® Windows® platforms:

    I = imread('c:/tools/goodstuff/img.png')
    
  • path on UNIX® platforms:

    I = imread('/home/tools/goodstuff/img.png')
    

Upvotes: 1

matlabgui
matlabgui

Reputation: 5672

You need to put ' around the filename and the file is probably named 'img.png' (a dot not a comma)

A = imread('d:/img.png')

Upvotes: 4

Related Questions