- ‘lat_ncep’ has dimensions as 1 * 360
- ‘lon_ncep’ has dimensions as 1 * 180
Matrix Dimension Must Agree
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi I want to ask why 'matrix dimension must agree' is happen during running the coding for plotting the HDF5 data.
Here is my coding, i also attach the sample data
Error using pcolor (line 56)
Matrix dimensions must agree.
Error in hdf5 (line 13)
pcolor(lon_ncep,lat_ncep,var1);
% clear all
% close all
% clc
%
file=hdf5info('Q2014031.L3m_DAY_SCI_V5.0_SSS_1deg')
dset1=hdf5read(file.GroupHierarchy.Datasets(1));
dset2=hdf5read(file.GroupHierarchy.Datasets(2));
var1 = dset1
var1 = rot90(fliplr(var1));
var1(var1==-3.2767)=NaN;
lat_ncep = linspace(0,14,360);
lon_ncep = linspace(95,126,180);
pcolor(lon_ncep,lat_ncep,var1);
shading flat
c = colorbar;
ylabel(c,'C')
load coast
hold on
plot(long,lat,'black')
title('GSSTFM NCEP Sea Surface Temperature')
xlabel('degrees longitude')
ylabel('degrees latitude')
0 commentaires
Réponses (1)
Sachin
le 21 Mar 2023
Modifié(e) : Sachin
le 21 Mar 2023
I understand that you are getting this error 'Matrix dimensions must agree'.
This is because of matrix dimensions of the matrices being used in your code do not match.Specifically, when you are using pcolor function then the size of inputs to the function must be of the same size.
Therefore, to resolve this error, you need to ensure that the matrices you are using with the 'pcolor' function have the same dimensions.
pcolor(lat_ncep,lon_ncep,var1) function have three inputs ‘lat_ncep’,’lon_ncep’ and ‘var1’ . So They all must be of the same dimensions.
Refer the following page for more information about pcolor:
Voir également
Catégories
En savoir plus sur HDF5 dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!