Can I import data into a table where the columns become variables?

1 view (last 30 days)
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
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?
Sophie Chumas
Sophie Chumas on 15 Jul 2019
I have code and an idea of how I wish to carry out the bullet points but was just wondering if you’d mind giving me “pointers” as apposed to giving me pure code since yes, it is an assignment and thus must be my own work...
Thanks :)

Sign in to comment.

Accepted Answer

Walter Roberson
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()

More Answers (0)

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!