conv2: First and second arguments must be numeric or logical

E
Emmitt · Oct 31, 2020 · 1.9K views
Question
I continue to get the same issue although I have two matrices using only integers. h1 = {-1, -2, -1; 0, 0, 0; 1, 2, 1}; ogI = imread('image.jpeg'); I = rgb2gray(ogI); I1 = conv2(I, h1, 'same'); imshow(I1);   Even if I set 'I' to a single or double inside of the function it does not work. This may be trivial but anything would help.
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Aug 24, 2026

You are defining h1 as a cell array. Define it as a numeric array

 

h1 = [-1, -2, -1; 0, 0, 0; 1, 2, 1]; % use square brackets
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!