Matlab Missing Matlab operator

  • Thread starter Thread starter Salam
  • Start date Start date
  • Tags Tags
    Matlab Operator
Click For Summary
SUMMARY

The discussion addresses a common error encountered in MATLAB when attempting to read multiple images using the imread function. The original code fails due to a syntax error, specifically a "Missing MATLAB operator" message. The solution involves concatenating the string components of the file name using square brackets, resulting in the corrected line: cur=imread(['salam(' int2str(counter) ').jpg']);. This adjustment allows the imread function to properly interpret the file name as a single string.

PREREQUISITES
  • Basic understanding of MATLAB syntax and functions
  • Familiarity with image file formats, specifically JPEG
  • Knowledge of string manipulation in MATLAB
  • Experience with loops in programming
NEXT STEPS
  • Explore MATLAB string concatenation techniques
  • Learn about MATLAB's imread function and its parameters
  • Investigate error handling in MATLAB programming
  • Study image processing techniques in MATLAB
USEFUL FOR

Beginner MATLAB programmers, students learning image processing, and anyone troubleshooting MATLAB syntax errors.

Salam
Messages
2
Reaction score
0
Matlab " Missing Matlab operator"

Homework Statement



i am new to matlab, i am trying to read many images named , salam(1).jpg, salam(2).jpg,...,salam(n).jpg, and i am trying to put that in the imread function as shown in the code below

Code:
counter =1;
while (counter<5)
        cur=imread('salam(' int2str(counter) ').jpg');
        counter=counter+1;
end

but i am getting the following error

Code:
?         cur=imread('salam(' int2str(counter) ').jpg');
                                |
Error: Missing MATLAB operator.
 
Last edited:
Physics news on Phys.org


The problem is that imread is expecting a single string parameter. You need to concatenate the components of the file name, by wrapping them in square brackets:

cur=imread(['salam(' int2str(counter) ').jpg']);


-Will Dwinnell
http://matlabdatamining.blogspot.com/"
 
Last edited by a moderator:


Thank you very much Predictor, it is working now :)
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K