日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab 格式化文件,格式化matlab文件01_新建普通文件

發布時間:2025/3/19 循环神经网络 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab 格式化文件,格式化matlab文件01_新建普通文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

經常寫matlab文件時,有時需要自己文件包含一些格式化信息,比如加上時間、自己的姓名、郵箱等信息,使得文件看起來更正規、更舒服。

下面貼出之前收藏的從網上找的 格式化matlab新建文件 的腳本。

包含兩類文件,新建普通.m文件和新建函數文件。

只要把下面的m文件放到matlab能找到的系統路徑里。

nm dummy,就會自動生成一個dummy.m文件,且里面有格式化的自定義的時間、郵箱等信息。

新建普通腳本文件

nm.m

function nm(mname)

% NM is the abbreviation of 'new M-File'

% NM create a MATLAB function with entered filename

%

% NM creates a M-File having the entered filename and a specific

% structure which helps for creating the main function structure. It

% would be opened and the starting line for writting will be highlighted

% (Only available in R14 or higher). The actual working MATLAB Version

% will be also captured. If user forgot to enter code and execute the

% function, he will get a reminder to enter code in the function.

%

% to create M-Files and Funcitons in a quick Way.

%

% Example :

% ---------

% >> NM dummy

%

% %%%%%%%%%% BEGINN CODE %%%%%%%%%%

% % DUMMY ...

% %

% % ...

%

% %% AUTHOR : xxx

% %% $DATE : 16-Oct-2014 13:29:27 $

% %% $Revision : 1.00 $

% %% DEVELOPED : 8.1.0.604 (R2013a)

% %% FILENAME : dummy.m

%

% % Write here...

%

% %% End_of_File

% % Created with NM.m by xxx

% % Contact...: xxxxx@163.com

% % ===== EOF ====== [dummy.m] ======

% %%%%%%%%%% CODE - END %%%%%%%%%%

%

if nargin == 0, help(mfilename); return; end

if nargin > 1, error(' MSG: Only one Parameter accepted!'); end

ex = exist(mname,'file'); % does M-Function already exist ? Loop statement

while ex == 2 % rechecking existence

msg = sprintf(['Sorry, but M-File -< %s.m >- does already exist!\n', ...

'Do you wish to Overwrite it ?'], mname);

% Action Question: Text, Title, Buttons and last one is the Default

action = questdlg(msg, ' Overwrite M-File?', 'Yes', 'No','No');

if strcmp(action,'Yes') == 1

ex = 0; % go out of While Loop, set breaking loop statement

else

% Dialog for new M-File name

mname = char(inputdlg('Enter new M-File Name ... ', 'NEWM - New Name'));

if isempty(mname) == 1 % {} = Cancel Button => "1"

disp(' MSG: User decided to Cancel !')

return

else

ex = exist(mname,'file'); % does new M-File exist ?

end

end

end

CreationMsg = CreateM(mname); % Call of Sub-Function

disp([' MSG: ' CreationMsg])

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%% CREATEM %%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function s = CreateM(name)

% Sub-Function will write the M-File, open it and mark the starting write

% line

ext = '.m'; % Default extension for a M-File !!

filename = [name ext];

fid = fopen(filename,'w');

str_tmp1 = upper(name);

h1 = ['% ', str_tmp1, ' ...']; % HELP-Line's will be preset

h2 = '% ';

h3 = '% ...';

fprintf(fid,'%s \n', h1); % First 3 Lines will be write in file

fprintf(fid,'%s \n', h2); % "

fprintf(fid,'%s \n\n', h3); % "

% Writer settings will be consructed ...

author = '%% AUTHOR : xxx';

dt = datestr(now); date = ['%% $DATE : ', dt, ' $'];

rev = '%% $Revision : 1.00 $';

devel = ['%% DEVELOPED : ',version];

filenamesaved = filename; fns = ['%% FILENAME : ', filenamesaved];

% Line 5-10 will be write in File ...

fprintf(fid,'%s \n', author);

fprintf(fid,'%s \n', date);

fprintf(fid,'%s \n', rev);

fprintf(fid,'%s \n', devel);

fprintf(fid,'%s \n\n', fns);

% Reminder that user must enter code in created File / Function

lst = '% Write here...';

fprintf(fid,'%s\n', lst);

% Before last line, from where functionality does come

originl0 = '%% End_of_File ';

originl1 = '% Created with NM.m by xxx ';

originl2 = '% Contact...: xxxxx@163.com ';

fprintf(fid,'\n\n\n%s \n%s \n', originl0,originl1);

fprintf(fid,'%s \n', originl2);

% Last Line in the M-File

end_of_file = ['% ===== EOF ====== [', filenamesaved, '] ====== '];

fprintf(fid,'%s \n', end_of_file);

% Close the written File

st = fclose(fid);

if st == 0 % "0" for successful

% Open the written File in the MATLAB Editor/Debugger

v = version;

if v(1) == '8' % R14 Version

opentoline(filename, 12); % Open File and highlight the start Line

else

% ... for another versions of MATLAB

edit(filename);

end

s = 'successfully done !!';

else

s = ' ERROR: Problems encounter while closing File!';

end

%% End_of_File

% Created with NFCN.m by xxx

% Contact...: xxxxx@163.com

% ===== EOF ====== [nm.m] ======

總結

以上是生活随笔為你收集整理的matlab 格式化文件,格式化matlab文件01_新建普通文件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。