Working with Large Matrices in MATLAB
If you are dealing with an xnxn matrix in MATLAB and need to visualize it as a graph, export it to PDF, and include Hindi language labels or instructions, there are a few practical steps you need to know. This is not something the basic tutorials cover well, so here is how it actually works. The core task involves three pieces: plotting the matrix data, saving it as a PDF, and setting up proper text rendering for Hindi script. MATLAB can handle Devanagari script if you configure the font correctly, but most people skip that step and wonder why their output looks like garbage characters instead of Hindi. First, create your matrix. A standard xnxn matrix just means a square matrix of size x by x. You can generate one with something like A = rand(10) for a 10x10 matrix, or load one from your own dataset. Then you plot it. The most straightforward approach is using imagesc(A) which renders the matrix as a color-mapped image, or surf(A) if you want a three-dimensional surface plot. For adjacency matrices or graph representations, plot(A) might be appropriate depending on your structure.
Here is where people usually hit a wall. Saving to PDF seems simple enough with print('output.pdf', '-dpdf'), but the Hindi text often comes out corrupted. The fix is to explicitly set the figure's renderer and font before exporting. Use set(gcf, 'Renderer', 'painters') because the default OpenGL renderer does not handle Unicode text properly when exporting to vector formats like PDF. Then set your label font to one that supports Devanagari, such as Noto Sans Devanagari or Mangal, which is installed on most Windows machines with Hindi language support. Example: set(gca, 'FontName', 'Noto Sans Devanagari', 'FontSize', 12)
title(' ', 'FontName', 'Noto Sans Devanagari')
xlabel(' ()', 'FontName', 'Noto Sans Devanagari')
ylabel('', 'FontName', 'Noto Sans Devanagari') I spent about three hours last year debugging this exact problem when a colleague needed a PDF report with Hindi annotations for a university project in Pune. The issue was not just the font, but the fact that my system's MATLAB installation had its locale set to US English, which caused the text encoding to break silently during the print operation. The workaround was adding feature('DefaultFigureVisible', 'on') before any rendering and explicitly calling exportgraphics(gcf, 'report.pdf', 'ContentType', 'vector') instead of using print. The exportgraphics function handles Unicode much more reliably in recent MATLAB releases, though it requires R2020a or later.
For the graph visualization itself, if your matrix represents a weighted graph or adjacency data, you might want to use graph() and plot() instead of image-based plots. G = graph(A); plot(G) gives you a network diagram. But be aware that for large xnxn matrices, say anything above 50x50, the graph plot becomes nearly unreadable. The edges overlap heavily and the layout algorithm struggles. In those cases, an image or heatmap approach is far more practical and renders much faster. One counter-intuitive thing about exporting MATLAB figures to PDF is that vector quality is not always better. For matrices larger than about 20x20, a high-resolution PNG exported at 600 DPI often looks cleaner in the final PDF than a vector version, especially when you have many colored cells or dense graph edges. Vector PDFs can become enormous file sizes and some PDF readers render them slowly or incorrectly. I usually stick with 600 DPI PNG export for matrix visualizations and embed that in the PDF rather than relying on pure vector output. There are limitations you should be aware of. Hindi text rendering in MATLAB depends entirely on the fonts available on your machine and the operating system. On Linux systems, you may need to manually install Devanagari fonts and clear MATLAB's font cache using rehash fontcache. On macOS, Noto fonts are not pre-installed, so you will need to download and register them through MATLAB's Font dialog. Also, older versions of MATLAB before R2016b have unreliable Unicode support for non-Latin scripts, so if you are on an older release, upgrading is probably easier than fighting the font system.
Get the Full Details

Another thing beginners miss: when your matrix is sparse, neither imagesc nor surf will show you useful detail because most entries are zero and the color scaling collapses everything into one hue. In that case, threshold your data first, or use spy(A) to visualize only the non-zero pattern, which is actually more informative for sparse xnxn matrices. For the PDF output with Hindi text, the reliable workflow is: configure fonts and renderer, generate the plot, use exportgraphics with vector or high-DPI raster content depending on your matrix size, and verify the output in an actual PDF reader before distributing it. Checking the PDF in a reader catches encoding issues that you cannot see in the MATLAB figure window because the figure window uses a different text rendering path than the export function.