How to save an unsaved function with your script?

조회 수: 1 (최근 30일)
1.sahne
1.sahne 2017년 1월 5일
댓글: 1.sahne 2017년 1월 5일
When running the Import data wizard and selecting the "generate MATLAB Code" box, a new function is created:
function [newData1] = importfile2(fileToRead1)
newData1 = importdata(fileToRead1);
Is there any way to save this function with the command window? So far it is called Untitled6 but not saved yet.
I can find it with
matlab.desktop.editor.getAll
Untitled_F=f(7) % the 7th open function is my "Untitled6" function
which gives me:
Untitled_F =
Document with properties:
Filename: 'Untitled6'
Opened: 1
Language: 'MATLAB'
Text: 'function [newData1] = importfile2(fileToRead…'
Selection: [11 1 11 1]
SelectedText: ''
Modified: 1
Editable: 1
but how can I save it now? Thanks for your help!
  댓글 수: 2
Greg
Greg 2017년 1월 5일
Why is simply clicking "Save As" in the Editor not an option?
1.sahne
1.sahne 2017년 1월 5일
The final script shall be a tool for physicists in the lab who want to plot their measurements quickly and in a consistent way. Thus I want to minimize the user Inputs and make it comprehensable for anyone.

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

답변 (1개)

Steven Lord
Steven Lord 2017년 1월 5일
Use the save or saveAs methods of the object Untitled_F. Since this is an Untitled buffer, I'd recommend saveAs.
help matlab.desktop.editor.Document.saveAs
For more information about the other methods and properties available in this API, look for help on matlab.desktop.editor.Document or matlab.desktop.editor.
help matlab.desktop.editor.Document
help matlab.desktop.editor

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by