Colorbar module error in GMT within MATLAB

I am using GMT6.6.0dev within MATLAB2023a on Windows10. So far, everything is fine except the colorbar module. For example,

My Bash code is ok,

gmt begin test png
 	gmt grdimage @earth_relief_01m -JM15c -R118/125/20/26 -Baf -BWSen -I+d
	gmt colorbar -DJMR+w10c+o1.5c/0c+ml -Bxa1000f -By+l"m"
gmt end show

my MATLAB code is wrong,

gmt('begin test png')
	gmt('grdimage @earth_relief_01m -JM15c -R118/125/20/26 -Baf -BWSen -I+d');
	gmt('colorbar -DJMR+w10c+o1.5c/0c+ml -Bxa1000f -By+l"m"');
gmt('end show');
gmt('destroy');

Error message,

错误使用 gmtmex
GMT: Attempting to address a prhs entry that does not exist


出错 gmt (第 33 行)
		[varargout{1:nargout}] = gmtmex (cmd, varargin{:});

出错 gmt_test (第 3 行)
gmt('colorbar -DJMR+w10c+o1.5c/0c+ml -Bxa1000f -By+l"m"');

Could anyone help me?

One possible reason is that when using GMT in Matlab, grdimage can read the hidden current cpt, but colorbar cannot. This means that colorbar needs an input parameter - cpt.

In bash, colorbar finds the hidden cpt. You could add any cpt in the colorbar command to see if this is the problem.

Thanks

Very likely the same reason as in the other post. The MEX parser probably does not know that an automatic CPT has been created ans is expecting it to be passed as argument in the gmt('colorbar ... command.