salve one field in the same struct is possible?

example:
A.b=3;
A.c=4;
A.d=6;
save("vv",'-struct','A');
A.d=7;
save("vv",'-struct','A','d'); %%don run correctly
%i dont' want resave A.b A.c ..i want only resave A.d

4 Comments

A.d is NOT a struct though. It is just a scalar. And you can trivially save a scalar value. So why do you think you need to ave it as a struct?
piero
piero on 24 Jun 2023
Edited: piero on 24 Jun 2023
A is a struct
d is a field of struct
i want to save new value 'd' in struct
struct before modify:
A.b=3
A.c=4
A.d=6
struct after modify:
A.b=3
A.c=4
A.d=7
(but i don't want to resave A.b and A.c because in the code I'm developing the values A.b and A.c can have undergone changes and I just want to save them after pressing a button)
For the sake of other folks -- like me! -- who didn't realize this, the syntax
save("vv","-struct","A")
saves all the fields of the structure A as individual variables.
So, the question is whether one can just "append" d to the file, even though A.b and A.c may have changed.
here is correct..
but i don't want to add a field 'd' ..i want ro modified on file field 'd' (modifies on file)

Sign in to comment.

 Accepted Answer

I believe that
save('vv','-struct','A','d','-append')
will do what you want

More Answers (0)

Categories

Asked:

on 24 Jun 2023

Commented:

on 24 Jun 2023

Community Treasure Hunt

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

Start Hunting!