matlab截取字符串
2015-07-02 10:50
597 查看
刚想截取一个matlab字符串中间的一段字符,网上搜了一下,发现strfind这个函数是matlab用来查找字符串中的字符的。
help strfind得到的结果:
strfind Find one string within another.
K = strfind(TEXT,PATTERN) returns the starting indices of any
occurrences of the string PATTERN in the string TEXT.返回在这个字符串中所有出现过的位置
strfind will always return [] if PATTERN is longer than TEXT.如果没有目标字符串则返回空矩阵
Examples
s = 'How much wood would a woodchuck chuck?';
strfind(s,'a') returns 21
strfind('a',s) returns []
strfind(s,'wood') returns [10 23]
strfind(s,'Wood') returns []
strfind(s,' ') returns [4 9 14 20 22 32]
看它的例子发现这个函数很简单,我把我的例子也贴出来:
help strfind得到的结果:
strfind Find one string within another.
K = strfind(TEXT,PATTERN) returns the starting indices of any
occurrences of the string PATTERN in the string TEXT.返回在这个字符串中所有出现过的位置
strfind will always return [] if PATTERN is longer than TEXT.如果没有目标字符串则返回空矩阵
Examples
s = 'How much wood would a woodchuck chuck?';
strfind(s,'a') returns 21
strfind('a',s) returns []
strfind(s,'wood') returns [10 23]
strfind(s,'Wood') returns []
strfind(s,' ') returns [4 9 14 20 22 32]
看它的例子发现这个函数很简单,我把我的例子也贴出来:
clear all; close all; clc; HOGpath='D:\mycode\graduation_project_0403\occlusion\Cir\DATA_list_Circle_hog_data.txt'; indfir=max(strfind(HOGpath,'\')); indlas=strfind(HOGpath,'.'); xlyb=HOGpath(indfir+1:indlas-1);截取了最后一个‘\’和‘.’之间的字符串。
相关文章推荐
- Matlab与C++混合编程(依赖OpenCV)
- matlab和vs2008联合编程
- VS调用matlab
- Matlab之print,fprint,fscanf,disp函数
- MATLAB实现pettitt检验
- 用matlab检测斑马鱼重心
- matlab 中的 S-Function的用法(C语言)
- matlab图片扭曲
- matlab取整
- matlab 全部的随机数函数
- matlab批量删除
- 多普勒失真信号采样Matlab模拟分析
- 调教一下你的matlab,给等待加入一段waitbar
- eval 用法 matlab
- 图像配准实现(matlab篇)
- Hough变换检测直线
- Matlab与微积分计算
- matlab注意事项
- 大矩阵的分块乘法及matlab实现
- matlab条形图绘制函数用法