필터 지우기
필터 지우기

Excel file not found

조회 수: 5 (최근 30일)
khalida basheer
khalida basheer 2020년 9월 17일
댓글: khalida basheer 2020년 9월 17일
How can I make sure that the Excel file is in the current location of Matlab, and in the absence of it I create it from Matlab, the problem arises when I write for the first time . when I read the Excel file for the purpose of determining the current location of the writing, the error appears that the file does not exist (File 'C:\Users\kh\Documents\MATLAB\testall.xlsx' not found.)
for i=1:4
[complete2] = xlsread('testall.xlsx');
lr = size(complete2,1);
range = ['A',num2str(lr+1)];
xlswrite('testall.xlsx',ROIRmom(i).mom,1,range);
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 9월 17일
filename = 'testall.xlsx';
if ~exist(filename, 'file')
file does not exist yet, do something
end
[...]
complete2 = xlsread(filename);
[...]
xlswrite(filename, and so on)
khalida basheer
khalida basheer 2020년 9월 17일
filename = 'ccl.xlsx';
if ~exist(filename, 'file')
% % file does not exist yet, do something
xlswrite('ccl.xlsx',ROIlmom(1).mom,1,'A1');
for i=2:4
[complete2] = xlsread('ccl.xlsx');
lr = size(complete2,1);
range = ['A',num2str(lr+1)];
xlswrite('ccl.xlsx',ROIlmom(i).mom,1,range);
end
else
for i=1:4
[complete2] = xlsread('ccl.xlsx');
lr = size(complete2,1);
range = ['A',num2str(lr+1)];
xlswrite('ccl.xlsx',ROIlmom(i).mom,1,range);
end
end
The code worked by this way. I selected the storage method based on the presence and absence of the Excel file. Is this a good way????

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

답변 (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