Clear Filters
Clear Filters

How to convert a .PNG file to a different size

3 views (last 30 days)
I have existing .PNG file as an output from following:
%Plot I:
X=datenum(tvec_SDstart);
Y=Carr_Fvec/1e6;
Z=magSpectrumMat_dB;
Tstart_num=datenum(Tstart);
Tend_num=datenum(Tend);
%
[X, Y]=meshgrid(X,Y);
h=surf(X,Y,Z);
set(h,'EdgeColor','none')
%
grid off
axis tight
view([90 90]); %Set view angle as Top-Flat 2D plot
colormap(jet);
%
% Create title and label
ax=gca;
set(ax,'FontAngle','italic','FontSize',8,'XColor',[0.0784313753247261 0.168627455830574 0.549019634723663],'YColor',[0.0784313753247261 0.168627455830574 0.549019634723663]);
set(ax,'XDir','reverse','XTick',linspace(X(1),X(end),6),'XLim',[Tstart_num Tend_num]); % Set the plot with XLim between the user defined Tstart/Tend Time
datetick('x','HH:MM:SS.FFF','keepticks','keeplimits');
%
plotname_PSD = sprintf('PSD vs Time Collected on %s', datestr(Date));
title(plotname_PSD,'FontSize',16,'Color',[0.0784313753247261 0.168627455830574 0.549019634723663]);
xlabel('Time');
ylabel('Frequency (MHz)');
zlabel('Magnitude (dB)');
%
% Create colorbar
set(ax,'CLim',Plotscale);
colorbar;
%
% Print to PNG file
print(plotname_PSD, '-dpng');
%
Beside the file, I would like to convert to another long narrow PNG figure (w: 3 inches, L: 5.2 inches)
What is the best way to do this?

Accepted Answer

Image Analyst
Image Analyst on 16 Jan 2018
I think export_fig() lets you specify the saved image's rows and columns to get the size you want. https://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig

More Answers (0)

Categories

Find more on Discrete Data Plots 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!