Search code examples
excelmatlabmatlab-deployment

Matlab keep loading old excel sheet


I am facing this annoying problem in matlab. I tried to open excel sheet and read the specific column in matlab but matlab keep on reading the old excel file. I have even changed the path of the sheet but still problem persists. The file names are same but the are in different folders. each time when I have to read a file I give a file path. The code I am using is this.

srcdir = 'path to the file'; 
srcfiles = dir(fullfile(srcdir, 'name.xls')); 
a= xlsread('sheetname','B:B');

Do anybody knows about this problem?


Solution

  • Get the path relative to the dir of the .m and add that as first argument in xlsread

    A=xlsread('pathA/Name.xlsx','sheetname','B:B');
    B=xlsread('pathB/Name.xlsx','sheetname','B:B');