Unable to use xlsread to open a file

1 次查看(过去 30 天)
Hey everyone,
I'm trying to run the follwing code:
for i=1:10
fil_length= xlsread('\\some_pathway_here\Filament_Length_Data\Filament_Length_',num2str(i),'.xls')
end
However, I get an error: Error using xlsread (line 132)
XLSREAD unable to open file '\\some_pathway_here\Filament_Length_Data\Filament_Length_'.
File '\\some_pathway_here\Filament_Length_Data\Filament_Length_' not found.
When I run this code:
fil_length= xlsread('\\some_pathway_here\Filament_Length_Data\Filament_Length_1.xls')
without the num2str(i) part, I'm able to read the file. Is it not possible to run a function such as this? If not, are there any other ways that i could access my excel files inside a loop?
  1 个评论
Meghana Balasubramanian
My apologies, I realized i made an error with using the brackets. It should be:
for i=1:10
fil_length= xlsread(['\\some_pathway_here\Filament_Length_Data\Filament_Length_',num2str(i),'.xls'])
end

请先登录,再进行评论。

采纳的回答

Bruno Luong
Bruno Luong 2019-8-28
for i=1:10
fil_length= xlsread(['\\some_pathway_here\Filament_Length_Dat\Filament_Length_' num2str(i) '.xls'])
end

更多回答(1 个)

darova
darova 2019-8-28
2Untitled.png
  1 个评论
Walter Roberson
Walter Roberson 2019-8-28
No, initial \\ in Windows indicates a path for network access, and is proper.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by