Filter löschen
Filter löschen

Saving a 1x2 structure with 5 fields

1 Ansicht (letzte 30 Tage)
Jocelyne Beelen
Jocelyne Beelen am 14 Jul. 2016
Kommentiert: Stephen23 am 15 Jul. 2016
I am trying to save my structure that I've called "mymat" in the workplace area as a file. When I try to save it like:
>> save ('mysummat.mat', '-struct', 'mymat');
I get the error message:
Error using save
The argument to -STRUCT must be the name of a scalar structure variable.
When I try to save it like:
>> save ('mysummat.mat', 'mymat')
I get the error message:
Error using save
Unable to write file mysummat.mat: No such file or directory.
I just want to be able to save this structure array specifically.
  1 Kommentar
Stephen23
Stephen23 am 14 Jul. 2016
Bearbeitet: Stephen23 am 14 Jul. 2016
Never use the name of an inbuilt function to name your own function or variable
This means you should never use sum, length, mean, size, i, j, etc, etc.
This will only cause untold heartache and hard to diagnose problems. Use which to check names before you use them.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 14 Jul. 2016
First, avoid using sum as a variable because it's a built-in Matlab function
som.a=4
som.b=5
save ('mysum.mat', '-struct', 'som')
  5 Kommentare
Jocelyne Beelen
Jocelyne Beelen am 15 Jul. 2016
I just want to save the entire structure that's called mymat in the workspace as a file. Is this possible?
Stephen23
Stephen23 am 15 Jul. 2016
save('myFileName.mat','mymat')

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by