Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to write to a file from anywhere?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am creating a program that checks simulink models for errors and log those errors in an excel spreadsheet. This sheet is stored in the script folders, and multiple functions write to it. Right now the program will break when I am not currently in the scripts folder, but I want to know if there is a way for me to not be in the script folder while the program is running and it still works?
function eraseWhiteSpace(app)
%%%%%%App Specific Stuff
% stop the timer while we are running
stop(app.projectTimer);
% disable the generate button while we are running
%app.RunCleanupButton.Enable = 'off';
app.StatusArea.Value = 'Running erase whitespace function. This can take awhile...';
filename = app.TopModelEditField.Value;
[folder, system, extension] = fileparts(filename);
load_system(system);
%%%%%%End App Specific Stuff
%Remove Old whitespace findings mat file
projects = slproject.getCurrentProjects;
projectRoot = projects.RootFolder;
saveFolder = [projectRoot '\scripts'];
saveFileFullName = [saveFolder '\whiteSpaceFindings.mat'];
warning('off','all')
baseFileName = 'ErrorReport.xlsx';
fullFileName = fullfile(saveFolder, baseFileName);
xlswrite(fullFileName ,baseFileName,'ErrorReport');
warning('on','all')
R = table(Diagram,portsWithBlanks,'VariableNames',varNames);
writetable(R,baseFileName,'Sheet','PortsWithBlanks');
댓글 수: 4
Anna Case
2020년 4월 27일
You could try using "[fPath '\' fName]" to specify where to save your excel file where:
[fPath, fName, fExt] = fileparts(fullfile(path,file));
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!