I am struggling to edit the ActionInfo in DQN_agent_Sell_Trained.mat file. I have tried to use the examples at Access and change variables in MAT-file without loading file into memory - MATLAB (mathworks.com) but was not successful. I have tried
ActionInfo_Sell=some filetype
DQN_agent_Sell_Trained = matfile('DQN_agent_Sell_Trained.mat','Writable',true);
DQN_agent_Sell_Trained.ActionInfo=ActionInfo_Sell;
However, when I run the code, a new ActionInfo variable is added instead of overwriting the ActionInfo with ActionInfo_Sell. Any clue on how to solve my problem? I have attached the file. Or to make my question simple, how do I replace or edit ActionInfo variable within the DQN_agent_Sell_Trained.mat file?

Antworten (1)

Image Analyst
Image Analyst am 25 Mär. 2023

0 Stimmen

Why do you not want to read it into memory? Why not simply do
% Load mat file into a structure.
s = load('DQN_agent_Sell_Trained.mat');
% Get one of the variables that we want to alter.
DQN_agent_Sell_Trained = s.DQN_agent_Sell_Trained
% Then modify DQN_agent_Sell_Trained somehow.
% Then save it back out:
save('DQN_agent_Sell_Trained.mat', 'DQN_agent_Sell_Trained', '-append');

4 Kommentare

Ivan Tadiwanashe Chuma
Ivan Tadiwanashe Chuma am 25 Mär. 2023
The part of modifying DQN_agent_Sell_Trained is the one I need help with. Also how can I modify DQN_agent_Sell_Trained considering its read-only?
Image Analyst
Image Analyst am 26 Mär. 2023
I have no idea how you want to modify it. How about you just set it equal to 1? If not, then what do you want to do to it?
If the file is readonly and you want to change it, you should use the operating system to remove the readonly property from the file.
Lets say I want to set ActionInfo = 1, how do I do it? I have tried
s = load('DQN_agent_Sell_Trained.mat');
DQN_agent_Sell_Trained = s.DQN_agent_Sell_Trained
DQN_agent_Sell_Trained.ActionInfo = 1 %Just an example
But I am getting the notification error that the file is read-only. Kindly assist.
Image Analyst
Image Analyst am 26 Mär. 2023
If the file is readonly and you want to change it, you should use the operating system to remove the readonly property from the file.

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Version

R2023a

Gefragt:

am 25 Mär. 2023

Kommentiert:

am 26 Mär. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by