How do I fix writematrix error?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am a beginner with MATLAB and am currently working on a code (part of it is legacy [from people outside my lab as I understand it], most is written by previous students) that involves simulating and saving results to an Excel sheet.
I am getting an error now, one that I never got at all since I started working (past 4 months) and I have been following the same procedure to simulate:
- Execute a script (This adds the path to current folder) that creates an initial excel file with variable names.
- Run the simulation script which runs for about 9 iterations and terminates once an optimal point has been found. The results are overwritten every iteration (I think, but not fully sure).
The error I get is:
Error using writematrix (line 206)
Unable to write to file 'D:\Applie Energy Simulations\AG_Opt-master\INRCD\Results\Uganda\Uganda_7.xlsx'. You may not have write permissions or the file may be open by another application.
Error in save_excel_data (line 25)
writematrix(value_2,file, 'Sheet', 'Results', 'Range', strcat(Column(Yr), string(location_2)));
Error in mg_cost (line 71)
save_excel_data(costPV,73, 2);
Error in mg_objfunction (line 6)
[myf,myc,myceq] = mg_cost(x_micro);
Error in sys_objfunction_eval (line 32)
y = mg_objfunction(x_micro); % calculate cost of microgrid subsystem
As I mentioned, I have been using the same in the past and have never received this error until recenty. I tried re-installing MATLAB R2021b, running MATLAB as admin, created a new directory with a copy of the code and ran it there. None fixed this issue. Please suggest how I can debug/ fix this. Appreciate any help!
7 commentaires
Cris LaPierre
le 9 Nov 2022
It sounds like you do not have write permission to the desired location. Try changing the write destination to somewhere else you have been able to write to in the past and see if the error goes away. You might also try running MATLAB as an administrator to see if that let's you write to that location.
In Windows, you can right click on the MATLAB Icon to select 'Run as Administrator'.
Jan
le 10 Nov 2022
"I am not sure how to check if I have priveleges to edit the file." - open the file, edit it, save the file. If this does not show an error message, you have the privileges to modify the file.
Réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!