Matlab入门学习笔记
因为科研过程中需要复现一篇论文的matlab代码;因此对matlab进行简单学习并记录学习过程;
1.参考博文:
(1)https://blog.csdn.net/LateNight_LL/article/details/125055998
(2)https://blog.csdn.net/lhm383/article/details/124576151
2.自己总结的matlab中一些基本的用法:
(1)存储文件:
function [res] = save_file(fname, cont)
fid=fopen(fname, 'a+');
fprintf(fid,'%.4f ',cont);
fprintf(fid, '\n');
fclose(fid);
res='finish!';
fprintf(res);
(2)字符换格式化:
a='sdf'
b=sprintf('%s haha',a)
则b='sdf haha'
(3)文件拼接:
参考:
https://blog.csdn.net/weixin_44867114/article/details/126682054
(4)文件夹遍历
参考:
https://blog.csdn.net/yunqianrui/article/details/124683555
(5)matlab中下表索引是从1开始的;
(6)matlab中使用索引时是不能嵌套的;
(7)matlab中计时:
tic
...
toc
(8)替换字符串中的字串
str='1.txt'
regexprep(str,'.txt','.mat')
则输出'1.mat';