I want to import string values from a .csv file and use them in MATLAB. I used readtable() and table2array functions in order to get an array of string values.
The csv file has 10 string values shown in below:
banana
apple
orange
lemon
apple
lemon
strawberry
apple
watermelon
orange
When I run my code I am supposed to an 1x10 array and it should have started with 'banana' but I get an 1x9 array and my first string is 'apple' not banana. In other words, I can't get the first value of the array. Can you help?
a = readtable('C:\Users\cinar\Desktop\Test Values.csv');
a = table2array(a);
banana?readtableassumes that your CSV file has a header. Remove the semicolon on your first line of code and you'll see that it has used'banana'as the header.readableis the wrong function. Try another function, e.g.,dlmreadorimportdataortextscan. It's impossible to give you code without seeing your actual CSV file.