matlab路径(string)操作及基本data读取保存
来源:互联网 发布:北京软件技术学院 编辑:程序博客网 时间:2024/06/05 12:37
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1 ## build a matrix; Why is matrix ? % one studentstudentScores = [90 99 98 85];% gammar math english moralrates = [0.3 0.3 0.3 0.1];jiDian = studentScores * rates'; % many studentsstudentScores = [90 99 98 85 % good style; a line with ';' is ok 80 70 59 90 72 89 65 99];% gammar math english moral rates = [0.3 0.3 0.3 0.1];jiDians = studentScores * rates'; % size whos double() uint8() char() size(studentScores);whos('studentScores');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 ## save : save() % save studentScores and jiDians in ScoresOfClass1.matsave('ScoresOfClass1.mat', 'studentScores', 'jiDians');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 ## load : load() sprinf() disp() fopen() fprintf()Scores = load('ScoresOfClass1.mat', 'studentScores');Scores = Scores.studentScores;JiDians = load('ScoresOfClass1.mat', 'jiDians');JiDians = JiDians.JiDians; % displaydisp(sprintf('Part %d is done ! Have a rest !', 1));sprintf('Part %d is done ! Have a rest !', 1) % enough % txt associated fprintftxtFile = fopen('log3.txt', 'w');name = 'xiaoming';fenshu = 2100;fprintf(txtFile, '%s score is %d; \n', name, fenshu);fprintf(txtFile, '%s score is %d; \n', 'xiaohong', 80); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 ## load a mat with absolute path : size() whos() structdata = load('C:\matlab\picture.mat'); % absolute pathdata = load('picture.mat'); % relative pathsize(data);whos('data'); % structstudent.name = 'chenhui';student.class = 2;student.age = 18;whos('student');data = data.Img;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5 ## plot max min find mean var std : figure() plot() subplot() bar()% max() min() mean() var() std()% find() subRow = data(1,:); % row vectorsubCol = data(:,1); % col vectorfigure(1); plot(subRow);figure(2); imshow(data, []);figure(3); subplot(1,2,1); plot(subRow); title('subRow');subplot(1,2,2); imshow(data, []); title('data');figure(1)A = 1:10;plot(A)B = 5:0.1:6;plot(B)plot(A)hold onplot(B)data2 = 1:10;figure(4); bar(data2);max(subRow); max(subCol);min(subRow);data2 = [4 5 9 6 10 12 52 45 99 10 0 25 56 ];find(data2==5);find(data2>=14);find('asdsxadsss'=='a');id = find(data2==10); % think max(data2(id(1):end));max(data2(id(end):end));mean(subRow);std(subRow);var(subRow); % max of a 2-D matrixmax(max(data));A = [1 2 3; 4 5 6];mean(A);mean(A,1);mean(A,2);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 ## functioncompute(data2);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 ## load files way 1 : ls() strcat()filePath = 'C:\matlab';fileNames = ls(filePath); % all files % strcat ls filePathOfMat = strcat(filePath, '\*.mat');fileNames = ls(filePathOfMat); % specific files[m,n] = size(fileNames);for i=1:m subData = load(fileNames(1,:)); subData = subData.Img; plot(subData(:,4));end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8 ## string manipulation : strcat() strrep() sprintf() path = 'C:\matlab';fullPath = strcat(path, '\A123.mat');fixPath = strrep(fullPath, 'A123', 'D_D'); % savefor i=1:10 str = spritnf('\%d.mat',i); str_fullPath = strcat(path, str); Result = xxxx; save(str_fullPath, 'Result');end % loadfor i=1:10 str = spritnf('\%d.mat',i); str_fullPath = strcat(path, str); data = load(str_fullPath, 'Result'); data = data.Result;end
阅读全文
0 0
- matlab路径(string)操作及基本data读取保存
- matlab 文件目录及路径操作
- matlab路径操作实例(真正实现data和code分离)
- Matlab 基本命令、快捷键及常用操作
- List<Map<String, List<String>>> data保存到SharedPreference和读取
- OpenCV2中图像读取、显示、保存等基本操作
- matlab 基本关于文件创建,读取的操作
- MATLAB文件操作及保存文件save load fopen
- C++中string类及文件流类(ofstream,ifstream)的基本操作---按行读取文档
- MATLAB读取文件+保存文件
- Matlab 对路径的操作及读写文件
- Matlab 对路径的操作及读写文件
- Matlab 对路径的操作及读写文件
- Matlab 对路径的操作及读写文件
- []matlab 路径操作
- matlab 路径操作
- matlab---文件路径操作
- TreeView保存及读取
- activeMQ
- 通过射线检测 获取到某个点的颜色值
- 要写的博客
- Jquery中.attr()和.data()的区别
- 多线程编程(二)
- matlab路径(string)操作及基本data读取保存
- Caravan Robbers UVA
- 新手之路--spark
- matplotlib 时间轴绘图
- HDU
- PAT 1074. Reversing Linked List (25)
- HIVE学习笔记:初识HIVE
- 用*打印三角形和菱形
- The Google File System : part6 MEASUREMENTS