Error using image Color data must be an m-by-n-by-3 or m-by-n matrix. Error in imagesc (line 52) hh = image(varargin{:}, 'CDataMapping', 'scaled');
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I dont understandf the problem here I am trying to plot sea velocity, and my EVO matrix is 4-D double, but it wont work. I tried using dimread, but it does not recognize the function
dir = 'C:\Users\Madison-Riley\Downloads\'
ncfile= 'Sea.Velocity.nc'
ncdisp([dir,ncfile]);
lat = ncread([dir,ncfile],'latitude');
lon = ncread([dir,ncfile],'longitude');
NVO = ncread([dir,ncfile], 'vo');
EVO = squeeze(ncread([dir,ncfile], 'uo'));
imagesc(lon,lat,EVO);
colormap jet;
colorbar
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 3 Jun. 2023
As the error message says, the image data you pass into imagesc must be a matrix (if it's an indexed image or a grayscale intensity image) or a 3-D array with size 3 in the third dimension (for an RGB truecolor image.) See this documentation page for more information about the image types.
A 4-D array like you have is neither a matrix nor a 3-D array. [You used the term "matrix" in your question, but that has a different meaning in MATLAB than the way you're using it. Your array wouldn't satisfy the requirements of the ismatrix function, so it's not a matrix.] Therefore it is not valid image data for imagesc.
A = ones(4, 4, 3, 6);
ismatrix(A)
If your data represents a collection of images, you might want to use the imtile function, create a tiledlayout of axes and display each image from your collection in a different axes using a for loop, or use the montage function from Image Processing Toolbox.
0 Kommentare
Weitere Antworten (1)
Rumana
am 5 Sep. 2023
Hello I am also facing same..How you have corrected?
1 Kommentar
DGM
am 6 Sep. 2023
OP never provided enough information for any of us to know that you are indeed facing the same error, or whether any particular solution is appropriate.
Since OP is gone, you have to explain exactly what you are trying to do and what error you are getting.
Provide some example code and data. If you can't share real data, you can provide some small amount of placeholder data, or at least appropriate information about the array size and type. If your application is similar to OP's, then it would help to know what quantities are described by the third and fourth dimensions of the main data array.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!