필터 지우기
필터 지우기

How to convert a .PNG file to a different size

조회 수: 3 (최근 30일)
Ivy Chen
Ivy Chen 2018년 1월 16일
답변: Image Analyst 2018년 1월 16일
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?

채택된 답변

Image Analyst
Image Analyst 2018년 1월 16일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by