%Example of how to use mfscsvread % Assumes existance of 2 files in the same director % with the names test.csv & data1.csv clear all; close all; inputdata = mfcsvread('data1.csv') figure % Plot using the "inputdata" structures field names plot(inputdata.Time,inputdata.Counts,inputdata.Time, inputdata.DAC) inputdata2 = mfcsvread('test1.csv') % names = fieldnames(inputdata2) % Get the structures field names names = char(fieldnames(inputdata2))% Get the structures field names as an % string (ascii array) (using "char" to % convert the field data to a string % array % use a dynamic structure name (computed above) to access inputdata2 % (using deblank to remove trailing blank spaces in the string field name figure plot(inputdata2.(deblank(names(1,:))),inputdata2.(deblank(names(2,:))),'r') % or if you know the structures fields you can directly access them hold on plot(inputdata2.Counter,inputdata2.ActualPositionValues,'b') % create the legend using the structures field names with trailing spaces % removed legend(deblank(names(2,:)),deblank(names(3,:)))