博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
how change files in matlab2 , cell 函数的运用
阅读量:4041 次
发布时间:2019-05-24

本文共 1671 字,大约阅读时间需要 5 分钟。

function main    pics = dir('coil-20-proc');%list all the files in folder photo      name = extractfield(pics, 'name');% extract name fields into a cell array      index = ~ismember(name,[ {'.'},{'..'}]);%exclude current directory and parent directory      name = name(index);          arrayfun(@(x) change_name(name,x), 1:71,'UniformOutput', 0 );endfunction change_name(name, index)    pic = regexp(name, strcat(strcat('__',num2str(index)),'.png$'));%find out the original gif files      pic_index = cellfun(@(x) ~isempty(x), pic);% filter out gif files      name = name(pic_index);      before_name = cellfun(@strcat, repmat({'coil-20-proc\'},size(name)), name, 'UniformOutput', 0);% add photo prefix        png_index = cellfun(@(x,y) strfind(x,y)-1, name, repmat({'.png'},size(name)), 'UniformOutput', 0);      pic_name = cellfun(@(x,y) x(1:y), name, png_index, 'UniformOutput', 0 );%cell取子串        after_name = cellfun(@strcat, repmat({'result\'}, size(pic_name)), pic_name, 'UniformOutput', 0);% 加文件夹名         after_name = cellfun(@strcat, after_name, repmat({'__'}, size(after_name)), 'UniformOutput', 0);% 注意字符串包成cell        degree = [];    switch( floor(index / 18) )        case 0            degree = 'fourfive';        case 1            degree = 'onethreefive';        case 2            degree = 'twotwofive';        case 3            degree = 'threeonefive';    end        after_name = cellfun(@strcat, after_name, repmat({degree}, size(after_name)), 'UniformOutput', 0);        after_name = cellfun(@strcat, after_name, repmat({'.png'}, size(after_name)), 'UniformOutput', 0);            cellfun(@movefile, before_name, after_name)% change file names      end

转载地址:http://cvxdi.baihongyu.com/

你可能感兴趣的文章
Spring MVC @Transactional注解方式事务失效的解决办法
查看>>
js正则表达式限制文本框只能输入数字,小数点,英文字母
查看>>
Spring事务失效的原因
查看>>
mybatis获取数据库表字段名+数据
查看>>
使用springfox整合SpringMVC和Swagger
查看>>
JAVA静态代理和动态代理
查看>>
使用Navicat计划任务备份mysql数据库
查看>>
Java高并发,如何解决,什么方式解决
查看>>
深入理解分布式事务,高并发下分布式事务的解决方案
查看>>
分布式事务一些总结与思考
查看>>
Spring Cloud微服务架构实践与经验总结
查看>>
Spring Boot入门篇
查看>>
spring cloud服务的注册与发现(Eureka)
查看>>
Java IO流
查看>>
多线程
查看>>
互联网产品设计:产品即服务
查看>>
UrlreWirte的使用
查看>>
使用js定位到页面某个位子
查看>>
java获取客户端真实ip
查看>>
SWFUPLOAD的使用(java版)
查看>>