Why matlab reading data from csv file completely different ?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
muhammad choudhry
am 1 Dez. 2020
Kommentiert: muhammad choudhry
am 1 Dez. 2020
Hi,
I am reading first and 7 column from the csv file attached using the code below but whenever on workspace I check the csv file data it is completely different then
what I have in the csv file. Why is this happening?
Code:
%Read the CSV file and Extract data
data=csvread('Mesh.csv',1,0); % read the csv file, skip header row
plot(data(:,1),data(:,7)) % plot 2nd column vs 1st
xlabel('Cases')
ylabel('totalcell')
0 Kommentare
Akzeptierte Antwort
VBBV
am 1 Dez. 2020
The data in 2nd column of your csv file is treated as text since it was not pasted to excel file correctly,
See the attached file which is corrected now. Use readtable instead of csvread
2 Kommentare
VBBV
am 1 Dez. 2020
You can also use readmatrix
TT = readmatrix('Mesh.csv')
plot(TT(:,1),TT(:,7))
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/437423/image.png)
This is how plot looks like
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!