フィルターのクリア

How to edit a variable in a structure and save the changes?

34 ビュー (過去 30 日間)
Dimitrios Topouridis
Dimitrios Topouridis 2020 年 9 月 1 日
編集済み: Dimitrios Topouridis 2020 年 9 月 1 日
Hi,
i have a .mat file with a struct in it. The struct has various field and one of those fields has a variable, that i want to edit and then save the change. My attempt was following, which didnt lead me to a solution.
EDIT: Found a solution myself
matfile('LKAWeave\LKATestBenchWeave.mat','Writable',true);
LKATestBenchWeave.data.ActorSpecifications.Waypoints=waypoints(:,[2 1 3]);
save ('LKAWeave\LKATestBenchWeave.mat','-append')

回答 (1 件)

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020 年 9 月 1 日
編集済み: Abdolkarim Mohammadi 2020 年 9 月 1 日
You should first load the variable, then write the new value, and then save it. For example, for changing the value of the variable MyVar:
load ('MyData.mat', 'MyVar');
MyVar = 20; % new value
save ('MyData.mat', 'MyVar');
MATLAB automatically replaces the new value for the variable MyVar.

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by