Azzera filtri
Azzera filtri

Using the Save command to save a logical mask

21 visualizzazioni (ultimi 30 giorni)
Aaron Smith
Aaron Smith il 9 Ago 2017
Modificato: Stephen23 il 9 Ago 2017
I am attempting to use the Matlab save command to save a logical mask as a .mat file. The difficulty arises when I attempt to specify a path to save the file in. I need to be able to save the mask in a specific folder. I have tried multiple incarnations of this code:
handles = guidata(hObject);
Folder = uigetdir('C:\Users\c13459232\Documents\MATLAB\Completed code thus far\Mask');
filename = 'Mask_01.mat';
%handles.mask = mask;
save([Folder filename '.mat'], 'handles.mask');
guidata(hObject, handles);
handles.mask is the logical mask itself, created in another callback. I attempted to use the command form of save, I also tried simply saving handles.mask without any folder specified. The main error that occurs is Argument must contain a string but Matlab also does not recognize the mask with the error Undefined function or variable 'mask' also occurring. Is there something glaring I am doing wrong here?
  8 Commenti
José-Luis il 9 Ago 2017
Emphasizing what Stephen said, please accept the answer that best solves your problem.
Stephen23 il 9 Ago 2017
Modificato: Stephen23 il 9 Ago 2017
" By making mask = handles.mask, why is mask not simply the mask that i created handles.mask to share in the previous callback?"
It is.
" I understand what you mean now, that the logical mask itself isn't a variable because it is a matrix with a large number of values so the apostrophes are not necessary"
Not at all. The fact you have a matrix of values is irrelevant. What is relevant is that handles.mask is, in itself, not a variable. A variable has a name and that name can be found in some workspace. Can you see handles.mask in the workspace? No, you cannot. You can see handles in the workspace though. This means that handles is a variable. And, as the save documentation clearly states, save requires the name of a variable in the workspace. Not the name of a field of structure, not the title of a figure, not your aunts name, or anything else. Just the name of a variable. Knowing what a variable is is a very basic MATLAB concept, covered in the introductory tutorials:
Who mentioned anything about "the apostrophes are not necessary" ? I certainly didn't write that, and I cannot see that written in the answer below.
PS: "please accept the answer that best solves your problem." and also for many of your previous questions. Most volunteers do not like the feeling of being treated as a disposable service.

Accedi per commentare.

Risposte (1)

José-Luis il 9 Ago 2017
data = handles.mask;


Scopri di più su Author Block Masks in Help Center e File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by