Plotting images in Matlab 2026a
Show older comments
I frequently work with large matrices and usually I can use pcolor to plot these - but since I updated Matlab to 2026a I get an error everytime I use the same code to do something which worked in Matlab 2024a.
I can't share my data, but my code is as follows - where t is a 1713x1 datetime array; f is a 1x24001 double array and psd_dat is 1713*24001 double matrix.
I tried to use imagesc instead, and this works, but doesn't allow me to shift the y axis to a log scale, which I need to do. In the past, pcolor allowed me to do this easily.
Thanks for your help and please let me know if I can provide any further detail!
pcolor(t,f,psd_dat','edgecolor','none');
%imagesc(t,f,psd_dat');
%axis xy;
set(gca,'tickdir','out') %set tick marks to point outwards
xtickformat('dd-MM HH:mm');
xticks(t(1):0.5:t(end))
set(gca,'YScale','log');
1 Comment
Steven Lord
on 17 Sep 2026 at 5:49
but since I updated Matlab to 2026a I get an error everytime I use the same code to do something which worked in Matlab 2024a.
Please show us the full and exact text of the error message, all the text displayed in red in the Command Window (and if there are any warning messages displayed in orange, please show us those too.) The exact text may be useful and/or necessary to determine what's going on and how to avoid the warning and/or error.
Answers (1)
Star Strider
on 17 Sep 2026 at 1:39
I am not certain what you want, however one option is to use surf and then rotate it with the view function. Also, 'interp' might be a better choice for EdgeColor.
I can't get this to run here, however MATLAB Online produces this result using a calculated Gaussian as the 'image' --
clear all
close all
tic
t = datetime('now') + hours(0:1712).';
f = linspace(0, 100, 24001);
psd_dat = exp(-((0:numel(t)-1).'-800).^2/2E+5) * exp(-(f - 50).^2/1000) * 1000;
[mindat,maxdat] = bounds(psd_dat(:))
% figure
% contour(psd_dat')
%
% toc
%
% return
% figure
% surf(psd_dat.', EdgeColor='interp')
% colormap(turbo)
% title('Surface Plot')
figure
% surf(t,f,psd_dat','edgecolor','none');
surf(t,f,psd_dat','edgecolor','interp') % <-- ChANGED
%imagesc(t,f,psd_dat');
%axis xy;
set(gca,'tickdir','out') %set tick marks to point outwards
xtickformat('dd-MM HH:mm');
xticks(t(1):0.5:t(end))
set(gca,'YScale','log');
view(0,90) % <-- ADDED
toc

The image was copied and pasted.
.
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!