MATLAB: Opts.VariableTypes for any number of variables

delimited textimport optionsvariable types

Hi, I want to be able to import a table with ANY number of columns into my MATlab code.
opts.VariableTypes = ["double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double"];
With the above line, readtable works perfectly on my 25-variable (25-column) .csv file. My entire gui works exactly as I need, but only on this exact number of variables.
However, I need to be able to import ANY number of variables, all as doubles. Everything I've tried has given me error messages when I try to plot the imported table in my GUI later on. Three of the many things I tried are below. I'm sure some of them look really dumb to anyone who knows MATlab- I apologize, I was just trying some things out on my own.
This one did not work:
opts.VariableTypes = "double";
Neither did this one, which I tried because all of my variable names start with D:
opts = setvartype(opts,{'D*'},{'single','string'});
Nor did this one:
opts.VariableTypes = ["double", ... ];

Best Answer

opts.VariableTypes = repmat("double", 1, 25);
Change the number 25 in that line of code as appropriate for your file.