use char function to create a 9x4 array of alloy names to store the alloy names by alloy number/row number 1-9 in matlab

You can use the char function to create a 9x4 array to store the alloy names in Matlab. Here's an example code that demonstrates how to do this:

main.m
% create a 9x4 array of alloy names
alloyNames = char('Alloy 1', 'Alloy 2', 'Alloy 3', 'Alloy 4', 'Alloy 5', 'Alloy 6', 'Alloy 7', 'Alloy 8', 'Alloy 9');

% access the alloy name for a specific alloy number (row number)
alloyNumber = 3;
alloyName = alloyNames(alloyNumber, :);
disp(alloyName);
294 chars
8 lines

In this example, char is used to create a 9x4 array of alloy names. Each row corresponds to an alloy number, and each column corresponds to a character in the alloy name. To access a specific alloy name, you can use indexing to select the corresponding row from the array. For example, alloyNames(3, :) would give you the alloy name for alloy number 3.

Note that the char function is not limited to creating arrays of strings with exactly 4 characters. You can create longer or shorter alloy names as needed by adjusting the number of columns in the array.

gistlibby LogSnag