Can I import data into a table where the columns become variables?
1 view (last 30 days)
Show older comments
Sophie Chumas
on 15 Jul 2019
Commented: Sophie Chumas
on 15 Jul 2019
Hi,
I've been given a task to create a program that reads a file of data of any number of columns and rows, and can then allow the user to select a variable (column) to import and then create a histograph of it...
the data is of this format (before being imported):
Title = '....'
variables=' ', ' ' , ' ',...
I (number of instances of data) =...
thanks! :)
8 Comments
Guillaume
on 15 Jul 2019
The inclusion of part of the marking sheet clearly show that this is a summative assesment. When our students submit an assignment here, they also have to submit the following statement: "I hereby certify that the attached [..] is my own work except were otherwise indicated".
Are you prepared to reference and attribute any code given to you when you submit your coursework?
Accepted Answer
Walter Roberson
on 15 Jul 2019
You could use tableread() to read the data, but you would want to tell it to skip the three lines at top, and you would have to find some way of reading in the variable names.
You can use fopen() on the file, and fgetl() to read individual lines from the header, and then either fscanf() or textscan() to read the contents. Remember to fclose() afterwards.
You could use fileread() to read as a single long character vector, after which you could use strsplit() or regexp() to analyze the content; you would want to know about str2double()
0 Comments
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!