MATLAB: Save about 40 string to array and the save this array to file

arrayfilesavestrings

hi how can i save about 40 string to array ( for example The names of 40 people) into variable(array) and then save these names into file and then Retrieve them back to array

Best Answer

YourArray{1} = 'first string';
YourArray{2} = 'benchwarmer';
YourArray{3} = 'hot chocolate';
save('YourMATfile.mat', 'YourArray');
clear YourArray %to prove we got them back
TheData = load('YourMATfile.mat', 'YourArray');
YourArray = TheData.YourArray;
clear TheData
YourArray{3}