Prompt to import data from csv file with specific column vectors

5 views (last 30 days)
Hi everyone,
My task is to have matlab allow a user to open a file with the ability to later use these column vectors in a plot on an interval. I've dabbled into using csvread, but I can't seem to get it to work properly, so thats why I've shifted gears to look into the import data tool, because it works and it doesn't skew some of the data points like other commands. However, to pass this code onto the next person, I want to make it as simple as possible where they could run the code to be prompted to pick a .csv file, wherever it may be on their computer.
The other part of my question has to do with the intervals of plotting points. These files will typically see about 11,000 rows of data. What I would like some help on, is an efficient way to change the amount of points called out. I imagine I will later implement some sort of loop to eliminate the need for the user to edit code for optimal data points.
Whatever hints, tips or tricks you have are all greatly appreciated!! Thank you!

Answers (1)

KL
KL on 9 Feb 2018
One of the things I love about MATLAB is its extensive documentation. Here's a link for you
This does exactly what you intend to do. Combine it with a data importing function. If you're using relatively newer version, I'd highly recommend using readtable to import data.
Hope it helps!
  8 Comments
KL
KL on 9 Feb 2018
Hmm.. Do you have the file in the same folder as that of your prac8.m file? Nevertheless you could use absolute path since you get the path from uigetfile.
[FileName,PathName] = uigetfile('*.csv','Select the DVSS CSV file');
T = readtable(fullfile(PathName,FileName))
Also keep the whole thing in a folder where you have read/write access. If this doesn't resolve your issue, try the other commands such as csvread, dlmread, textscan etc.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!