Why matlab reading data from csv file completely different ?

조회 수: 2 (최근 30일)
muhammad choudhry
muhammad choudhry 2020년 12월 1일
댓글: muhammad choudhry 2020년 12월 1일
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')

채택된 답변

VBBV
VBBV 2020년 12월 1일
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
VBBV
VBBV 2020년 12월 1일
You can also use readmatrix
TT = readmatrix('Mesh.csv')
plot(TT(:,1),TT(:,7))
This is how plot looks like
muhammad choudhry
muhammad choudhry 2020년 12월 1일
Thanks for the help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by