Matlab Missing Matlab operator

  • Thread starter Thread starter Salam
  • Start date Start date
  • Tags Tags
    Matlab Operator
AI Thread Summary
The user encountered a "Missing MATLAB operator" error while trying to read multiple images using the imread function in MATLAB. The issue arose because the file name was not properly concatenated into a single string. The solution involves using square brackets to concatenate the components of the file name, changing the code to: cur=imread(['salam(' int2str(counter) ').jpg']). After implementing this fix, the user confirmed that the code worked correctly. Proper string concatenation is essential for successfully using the imread function in MATLAB.
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
Views
704
Replies
1
Views
2K
Replies
3
Views
1K
Replies
1
Views
1K
Replies
1
Views
1K
Back
Top