figure; surf(matrix_peaks); shading interp; % Smooths out the grid lines colorbar; title('3D Surface Plot of N x N Matrix'); Use code with caution. Categorical Heatmaps ( heatmap )
figure; plot(real(e), imag(e), 'ro', 'MarkerSize', 8, 'MarkerFaceColor', 'r'); grid on; xlabel('Real Axis'); ylabel('Imaginary Axis'); title(sprintf('Eigenvalues of %dx%d Random Matrix', n, n)); axis equal;
% Setup your figure handle fig = gcf; % Export directly to a vector PDF with cropped white margins exportgraphics(fig, 'matrix_plot.pdf', 'ContentType', 'vector'); Use code with caution. Method 2: Legacy Save Function
Elevate your matrix plots with professional touches:
imagesc(matrix);
Once your plot looks exactly how you want it, you can export it to a high-quality PDF directly from the MATLAB command window or via scripts.
For an N × N matrix, a heatmap is excellent for seeing the magnitude of values.
% Create a 6x6 magic square (all rows/columns sum to same value) C = magic(6);
There are several ways to save your figure as a PDF file directly from MATLAB:
print(gcf, 'matrix_plot_legacy.pdf', '-dpdf', '-r300'); % Saves at 300 DPI Use code with caution. 5. Troubleshooting Common Plotting Issues