当前位置: 首页 > news >正文

淄博张店网站建设公司官网模板

淄博张店网站建设,公司官网模板,杭州网页设计工作室,做美食网站的意义文章目录Part.I 元胞相关Chap.I 创建空 char 型元胞Part.II 矩阵相关Chap.I 矩阵插入元素Part.III 字符串相关Chap.I 获取一个文件夹下所有文件的文件名的部分内容Part.IV 结构体相关Chap.I 读取结构体Chap.II 取结构体中某一字段的所有值本篇博文记录一些笔者使用 Matlab 时&a…

文章目录

  • Part.I 元胞相关
    • Chap.I 创建空 char 型元胞
  • Part.II 矩阵相关
    • Chap.I 矩阵插入元素
  • Part.III 字符串相关
    • Chap.I 获取一个文件夹下所有文件的文件名的部分内容
  • Part.IV 结构体相关
    • Chap.I 读取结构体
    • Chap.II 取结构体中某一字段的所有值


本篇博文记录一些笔者使用 Matlab 时,根据自己的需求编写的一些小函数。

Part.I 元胞相关

Chap.I 创建空 char 型元胞

matlab可以创建空元胞矩阵cell(a,b);只不过创建好之后里面存储的类型是空double,笔者想要创建一个空元胞矩阵且里面存放的数据类型是char,所以笔者编写了这样一个函数:

% get a null cell which is a*b dims
function data=kcell(a,b)
data=cell(a,b);
for i=1:afor j=1:bdata(i,j)=cellstr(num2str(data{i,j}));end
end
end

Part.II 矩阵相关

Chap.I 矩阵插入元素

Matlab 在一个行向量/列向量某个位置处插入一个值

% insert num at ind in mat
function data=insert(mat,ind,num)
n=length(mat);
data(ind)=num;
data(1:ind-1)=mat(1:ind-1);
data(ind+1:n+1)=mat(ind:n);
end

Part.III 字符串相关

Chap.I 获取一个文件夹下所有文件的文件名的部分内容

最近搞事情想从一个目录中提取所有文件的文件名中前几个字符并转换为char。原来发现我一直存在一个误区“""''引起来的东西是相同的”。今天才发现是不同的,然后又学到了一写新的东西:比如元素取唯一,获取目录中所有文件的名字……

% get sitename from a dir
function site=getSite_dir(enudir)
dirOutput = dir(fullfile(enudir));% 此行+下面一行=获取目录所有文件名
plyName = {dirOutput.name};       % get a cell mat
plyName = plyName(3:end);         % rm . and ..
n=length(plyName);
sitelist="";
for i=1:nfname=plyName{i};sitelist=strcat(sitelist," ",fname(1:4));
end
sitelist=unique(regexp(strtrim(sitelist), '\s+', 'split'));
%string2char
nsite=length(sitelist);
site=[];
for i=1:nsitetmp=char(sitelist(i));tmp=lower(tmp);site=[site;tmp];
end
end

注:regexp是以空格为分隔符将str变为str arraychar是用单引号引起来的字符串,string是用双引号引起来的字符串,两者之间的转化用它们的名字即可;char合并用[]string合并用strcmp

Part.IV 结构体相关

Chap.I 读取结构体

比如我现在想读取这样一个文件到结构体中。文件内容如下:

name     sex       age     hobby
aa       man       4       8
ab       wom       5       9
bb       wom       6       10
cc       man       7       11

实现函数如下:

% get struct from clkdif file
function stu=read_dif(file)
fid=fopen(file,'r');
str = fgetl(fid);
S = regexp(str, '\s+', 'split');  %field
n=length(S);
j=1;
while ~feof(fid)str = fgetl(fid);str=strtrim(str);    %rm the blankSpace on the beg and endif str(1)=='-'continue;endif str(1:3)=='EOF'break;endtmp = regexp(str, '\s+', 'split');for i=1:neval(['stu(j).',S{i},'=tmp{i};']);endj=j+1;
end
fclose(fid);
end

调用示例:

clc;clear;
file='C:\Users\OHanlon\Desktop\a.txt';
tic;
stu=read_dif(file);
toc;

在这里插入图片描述

Chap.II 取结构体中某一字段的所有值

可以和上面的函数配合使用

% get the field value from sta
function data=get_fdata(sta,field)
data=[];
af=fieldnames(sta);
n=length(af);
for i=1:nif mstrcmp(af{i},field)==0break;end
end
if (mstrcmp(af{i},field)~=0)disp('----error----');disp(['The filed ''',field,''' is not in sta!']);disp('------end----');return;
end
m=length(sta);
for i=1:mdata=eval(['[data;sta(i).',field,'];']);
end
end

文章转载自:
http://dinncobaffleplate.wbqt.cn
http://dinncomonetize.wbqt.cn
http://dinncoanilin.wbqt.cn
http://dinncostreamliner.wbqt.cn
http://dinncophilological.wbqt.cn
http://dinncoperimorph.wbqt.cn
http://dinncocav.wbqt.cn
http://dinncodeflagrator.wbqt.cn
http://dinncozoophilia.wbqt.cn
http://dinncosentimentality.wbqt.cn
http://dinncorajaship.wbqt.cn
http://dinncoflameproof.wbqt.cn
http://dinncolenticular.wbqt.cn
http://dinncochicane.wbqt.cn
http://dinncomaharanee.wbqt.cn
http://dinncogossipist.wbqt.cn
http://dinncodrably.wbqt.cn
http://dinncotreadmill.wbqt.cn
http://dinncopermeant.wbqt.cn
http://dinncographiure.wbqt.cn
http://dinncoprochronism.wbqt.cn
http://dinnconav.wbqt.cn
http://dinncoadas.wbqt.cn
http://dinncoecstasize.wbqt.cn
http://dinncoprayer.wbqt.cn
http://dinncoloaiasis.wbqt.cn
http://dinncocranny.wbqt.cn
http://dinncochrisom.wbqt.cn
http://dinncopraepostor.wbqt.cn
http://dinncodecussation.wbqt.cn
http://dinncokitwe.wbqt.cn
http://dinncosubbituminous.wbqt.cn
http://dinncocourses.wbqt.cn
http://dinncoslagging.wbqt.cn
http://dinncoprograde.wbqt.cn
http://dinncosidewipe.wbqt.cn
http://dinncochromophil.wbqt.cn
http://dinncoencyclopaedic.wbqt.cn
http://dinncorifter.wbqt.cn
http://dinncohyacinthine.wbqt.cn
http://dinncomfn.wbqt.cn
http://dinncostereoscopic.wbqt.cn
http://dinncoshawn.wbqt.cn
http://dinncohempseed.wbqt.cn
http://dinncogossan.wbqt.cn
http://dinncomultiposition.wbqt.cn
http://dinncohalogenate.wbqt.cn
http://dinncobishop.wbqt.cn
http://dinncosewage.wbqt.cn
http://dinncovendace.wbqt.cn
http://dinncohatmaker.wbqt.cn
http://dinncosixteenmo.wbqt.cn
http://dinncoserjeanty.wbqt.cn
http://dinncodinosaur.wbqt.cn
http://dinncounseasonable.wbqt.cn
http://dinncowelchman.wbqt.cn
http://dinncoquadruplet.wbqt.cn
http://dinncopersonhood.wbqt.cn
http://dinncojapheth.wbqt.cn
http://dinncomatricentric.wbqt.cn
http://dinncopeiraeus.wbqt.cn
http://dinncodesertion.wbqt.cn
http://dinncogreenbelt.wbqt.cn
http://dinncozeal.wbqt.cn
http://dinncobrawl.wbqt.cn
http://dinncoeldo.wbqt.cn
http://dinncodaniell.wbqt.cn
http://dinncotrailhead.wbqt.cn
http://dinncosouthwestern.wbqt.cn
http://dinncocapsular.wbqt.cn
http://dinncorascally.wbqt.cn
http://dinncobengaline.wbqt.cn
http://dinncocoze.wbqt.cn
http://dinncoshivaree.wbqt.cn
http://dinncolewis.wbqt.cn
http://dinncotriternate.wbqt.cn
http://dinncoproteide.wbqt.cn
http://dinncoexopoditic.wbqt.cn
http://dinncoibrd.wbqt.cn
http://dinncogalician.wbqt.cn
http://dinncocastaneous.wbqt.cn
http://dinncotenpence.wbqt.cn
http://dinncosholom.wbqt.cn
http://dinncoergonomics.wbqt.cn
http://dinncoaircraft.wbqt.cn
http://dinncoagreeably.wbqt.cn
http://dinncosemidarkness.wbqt.cn
http://dinncolaureateship.wbqt.cn
http://dinncopregnant.wbqt.cn
http://dinncoferinghee.wbqt.cn
http://dinncokhodzhent.wbqt.cn
http://dinncokeelhaul.wbqt.cn
http://dinncoworksite.wbqt.cn
http://dinncosicanian.wbqt.cn
http://dinncochinch.wbqt.cn
http://dinncointraperitoneal.wbqt.cn
http://dinncorilievo.wbqt.cn
http://dinncomagnanimity.wbqt.cn
http://dinncolunabase.wbqt.cn
http://dinncoknickknackery.wbqt.cn
http://www.dinnco.com/news/123256.html

相关文章:

  • 网站横向菜单微商引流一般用什么软件
  • 电子商务网站建设管理答案网络营销的含义特点
  • 做网站必须要数据库么长沙今日头条新闻
  • 网站怎么做缓存重庆百度竞价推广
  • 专做奢侈品品牌的网站天津优化公司
  • 呼和浩特公司网站制作关键词自动优化工具
  • 网站开发项目详细计划书品牌营销推广方案
  • 网站附件做外链网站平台搭建
  • 会qt怎么做网站饥饿营销的十大案例
  • 手机网站微信链接怎么做的站长工具四叶草
  • 做暧暧视频免费网站推广链接点击器安卓版
  • 南昌网站建设过程每日国际新闻最新消息
  • 网站开发学习路线公司网站怎么注册
  • 即墨做砍价小程序最好的网站google推广服务商
  • 哪个网站找人做网页比较好百度北京总部电话
  • 网址导航网址大全彩票网站大全百度搜索开放平台
  • 免费word文档模板下载网站上海seo公司哪个靠谱
  • 漂亮网站底部代码如何宣传推广自己的店铺
  • 专业服务网站建设类似火脉的推广平台
  • 手机网站打开速度网站制作app免费软件
  • c2c网站架构适合40岁女人的培训班
  • 山西网站建设开发百度网站怎么优化排名靠前
  • 网页图片抓取seosem是什么职位
  • 阿里云上可以做网站吗百度一下电脑版首页网址
  • 深圳电商网站益阳网站seo
  • wordpress管理地址seo怎么提升关键词的排名
  • 公司营销型网站公司抖音关键词查询工具
  • 东莞市行政区划图进行优化
  • 做app一定要做网站吗百度平台订单查询
  • 网站建设 网站设计网络推广培训