Saving a logical mask

조회 수: 3 (최근 30일)
Aaron Smith
Aaron Smith 2017년 8월 3일
편집: Jan 2017년 8월 5일
I have a code for creating a logical mask and calculating values inside the ROI of the mask. My query is: is it possible to save the logical mask to the desktop so that it can be applied to other data in the future?
  댓글 수: 4
Stephen23
Stephen23 2017년 8월 4일
"As a file essentially so that in future I can just apply it to matrices. If this is possible"
It is possible and my answer shows you the simplest and most efficient way of doing this. Did you try it?
Jan
Jan 2017년 8월 5일
편집: Jan 2017년 8월 5일
@Aaron: I repeat my question: Does "save to the desktop" mean the path:
C:\Users\<USERNAME>\Desktop
? Or do you mean the desktop window of Matlab? Storing it on the desktop of the OS might be less convenient than storing it in the user path of Matlab.

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2017년 8월 3일
편집: Stephen23 2017년 8월 5일
Simply save it in a .mat file:
save('nameOfFile.mat','nameOfVariable')
and then load it back into memory:
S = load('nameOfFile.mat');
mask = S.nameOfVariable;
Use the relevant absolute/relative path to save it on the desktop.
  댓글 수: 1
Jan
Jan 2017년 8월 5일
편집: Jan 2017년 8월 5일
Explicitly:
desktop = fullfile(getenv('USERPROFILE'), 'Desktop');
save(fullfile(desktop, 'nameOfFile.mat'), 'nameOfVariable')
But I'd prefer the userpath of Matlab instead of polluting the OS's desktop.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by