Info

This question is closed. Reopen it to edit or answer.

Why is my matrix dimensions off?

1 view (last 30 days)
Brian Bowne
Brian Bowne on 25 Sep 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
So the goal is to create a matrix and convert that to an image. Below is my code. It runs and prints out a 10x10 matrix and the image, but the checker says y has a value of [1 1] instead of [10 10]. Why is that happening?
function [N,M] = smooth_image(x)
y=x
[N,M]=size(x)
for k=2:N-1
for c=2:M-1
y(k,c)=mean(mean(x(k-1:k+1,c-1:c+1)))
y
end
end
end
  6 Comments
Brian Bowne
Brian Bowne on 25 Sep 2019
That was it, I just had the wrong output. Thank you!
Adam Danz
Adam Danz on 25 Sep 2019
Edited: Adam Danz on 25 Sep 2019
That makes 3 of us who missed that!
Doh!

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!