Unable to open file 'Diabetes.csv'.

조회 수: 2 (최근 30일)
Madiha Rehman
Madiha Rehman 2022년 1월 18일
편집: Adam Danz 2022년 1월 18일
I'm new to matlab I'm having trouble with this one. Where should I put my excel file so MATLAB can read it?
Code:
%Read data
clc
clear all
close all
data=readtable ('Diabetes.csv');
Error:
Error using readtable (line 143)
Unable to open file 'Diabetes.csv'.
  댓글 수: 1
Star Strider
Star Strider 2022년 1월 18일
Be sure it’s on the MATLAB search path somewhere so that MATLAB can find it.
For help on that see What Is the MATLAB Search Path?.

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

답변 (1개)

Adam Danz
Adam Danz 2022년 1월 18일
편집: Adam Danz 2022년 1월 18일
To add to @Star Strider's advice, you can put the file anywhere you want as long as it's folder is on the Matlab path. For example, if the file is in C:\Users\name\Documents\Matlab\data then add the path using
addpath('C:\Users\name\Documents\Matlab\data')
Now Matlab will be able to access the file.
Alternatively, you can specify the full path to the file so Matlab knows where it's at even if it's not on the Matlab path,
filepath = 'C:\Users\name\Documents\Matlab\data';
filename = 'Diabetes.csv';
data = readtable(fullfile(filepath, filename));

카테고리

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

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by