"Data dimensions must agree" Error
51 views (last 30 days)
[code]im = im2double(imread('rice.png'));
[X Y]= meshgrid(1:size(im,1),1:size(im,2));
when i run this script it worked me fine but when i tried to change the image to RGB image it gives me this 2 errors
??? Error using ==> surf at 78 Data dimensions must agree.
Error in ==> CoOrdinating at 6 surf(zeros(size(im)),X,Y,im,'EdgeColor','none');
i tried to convert the image to grayscale but it didn't work with me and gave me the same errors
any help ?
Andrew Newell on 15 May 2011
Here is a demo that works:
rgb_img = imread('ngc6543a.jpg');
I = .2989*rgb_img(:,:,1)...
I = double(I);
Probably you didn't take the transpose of I in the surf command. I don't know why you need to do this, but you do.
More Answers (3)
Andrew Newell on 14 May 2011
If you enter the command
I = imread('rice.png');
you get a matrix. If you enter
I = imread('ngc6543a.jpg');
you get a 3D array with one page for each of the R, G and B components of the color. This does not have the same dimensions as the matrices X and Y.
guj on 15 May 2011
am also stuck in same thing I have samples point of 5:5:85 missing samples ..so i have 17 numbers which i have chosen has missing %.
so my vector is of length 17 by 1
Number of iteration = 500;
number of iteration carried out for reconstruction is 500 but 100 seems to be enough...so i have just zeros after 100 row my matrix is 500 by 17 in my error)matrix
I am using [X,Y]=meshgrid(iteration,missing sample) surf(X,Y,errormatrix(1:100,:))
But i am getting error...
whole objective is to show 3d graph having iteration on one axis, missing % of samples on other axis and error on the third one
This is what i am doing
[X,Y]=meshgrid(x,y) x=1 by 17 (decimation factors) y=1 by 100 (number of iteration)
errormatrix=[100 by 17] whch shows error during 100 iteration for each decimation %.
Error dimension at 78
Alexandra Roxana on 18 Jul 2021
Hello! I'm having the same problem. I want to plot the results from the following code:
alpha = 2;
dx = 1;
dt = (dx^2)/(4*alpha);
gamma = (alpha*dt)/(dx^2);
itert = 1000;
uinit = 0;
u(k+1,i,j) = gamma*(u(k,i+1,j) + u(k,i-1,j) + ...
u(k,i,j+1) + u(k,i,j-1) - 4*u(k,i,j)) + u(k,i,j);