matlabdialogcustomizationmatlab-guitext-coloring

Change the color of an inputdlg field name


This is my code:

classDefault={'','','','',''};
fieldNames= {'Class Number','Class Name'};
title='Enter Class Information';
numlines=1;  
y =inputdlg(fieldNames,title,numlines,classDefault);

it shows:

enter image description here

I want to change the color of the field name, like this:

enter image description here

How can I do this?


Solution

  • You can use the tex interpreter:

    function q65234922()
    classDefault = {'','','','',''};
    fieldNames = {'\color{red}Class Number','Class Name'};     % Change 1
    title = 'Enter Class Information';
    numlines = 1;
    opts = struct('Interpreter','tex');                        % Change 2
    y = inputdlg(fieldNames,title,numlines,classDefault,opts); % Change 3
    

    enter image description here