CSV file that needs to be run through MATLAB?

New to MATLAB. I have been given data in a CSV file that needs to be run through a given MATLAB code and I do not know where to even start. Can anyone help me?

6 Kommentare

Stephen23
Stephen23 am 9 Nov. 2018
Bearbeitet: Stephen23 am 9 Nov. 2018
Duplicate:
"Can anyone help me?"
You can help you, by reading the links that Star Strider gave you. They show how to import data. If you tried them and something did not work then please add comments to that question, showing exactly what you tried.
It does not help to simply ask the same question again and again.
I have looked through the links and they don't make sense to me.
Hi Kristine,
If you are looking to read from a CSV file, I would recommend starting with the "readtable" function in MATLAB. This should be able to read in the data and store it in a MATLAB table so that you can use it.
More information about this function can be found at the link below: https://www.mathworks.com/help/matlab/ref/readtable.html
Kristine McKay
Kristine McKay am 12 Nov. 2018
Hi Steven,
I have tried this but the following error has appeared.
Error in line 3
T = readtable('cardio_test_2, Value');
In the description the file is definitely a Microsoft Excel Comma Separated Values File (.csv).
The file is on a memory pen so I tried using the full path name and this doesn't change the error... What do you think?
Does the file name really have a comma and space in it? And does it really not have a file extension?
I speculate that you are interested in the column named Value in the file cardio_test_2.csv
T = readtable('cardio_test_2.csv');
T.Value
Kristine McKay
Kristine McKay am 12 Nov. 2018
Hi Walter,
This is what I now have currently but MATLAB is ignoring this line and jumping straight to the code
T = readtable('E:\Uni\Final\MATLAB\Assignment 1\cardio_test_2.csv');

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Andrew Padilla
Andrew Padilla am 12 Nov. 2018
Bearbeitet: Andrew Padilla am 12 Nov. 2018

0 Stimmen

Kristine,
Have you tried loading in the data using the csvread() function?
If you have a csv file that is named "Test.csv" you can import it to your workspace using the following:
data = csvread('Test.csv');

13 Kommentare

Kristine McKay
Kristine McKay am 12 Nov. 2018
Is this for the full file name?
Kristine McKay
Kristine McKay am 12 Nov. 2018
Come back with Error in B00690215_Assignment_1 (line 4)
data = csvread('cardio_test_2');
Kristine McKay
Kristine McKay am 12 Nov. 2018
Error in B00690215_Assignment_1 (line 3)
data = csvread('E:\Uni\Final\MATLAB\Assignment 1\cardio_test_2.csv');
What is the complete error message?
Have you posted an example of the csv file you are dealing with?
Kristine McKay
Kristine McKay am 12 Nov. 2018
Please see attached CSV file. I have moved on to try to use
T = table
T = table ('val1','val13');
Kristine McKay
Kristine McKay am 12 Nov. 2018
Walter, full error is
Error in csvread (line 48)
m=dlmread(filename, ',', r, c);
Error in B00690215_Assignment_1 (line 3)
data = csvread('E:\Uni\Final\MATLAB\Assignment 1\cardio_test_2.csv');
Andrew Padilla
Andrew Padilla am 12 Nov. 2018
Bearbeitet: Andrew Padilla am 12 Nov. 2018
Kristine,
you need to include the property of the file in the csvread() function. In other words, add the .csv.
Try this,
data = csvread('cardio_test_2.csv');
Kristine McKay
Kristine McKay am 12 Nov. 2018
Error in B00690215_Assignment_1 (line 3)
data = csvread('cardio_test_2.csv');
Andrew Padilla
Andrew Padilla am 12 Nov. 2018
Could you send a screenshot of your data set? I think it has something to do with the actual set of data that you are trying to work with.
Kristine McKay
Kristine McKay am 12 Nov. 2018
A screenshot of the CSV file?
It has a text column. It cannot be used with csvread() or dlmread(). You will need to use readtable() or textscan()
Kristine McKay
Kristine McKay am 13 Nov. 2018
Thanks all! This has helped!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by