matlab中字符串连接的几种方法
matlab中字符串连接的方法
N个字符串 串联连接在一起并输出
***第一种方法 [ ]字符串数组***
```matlab
str1='test_img';
str2='.png';
%test_img.png 是当前目录下的测试图片
file_name=[str1,str2];
im=imread(file_name);
imshow(im);
%output : file_name='test_img.png'
第二种方法 strcat( ) 水平串联字符串
str1='I';
str2=' love';
str3=' you';
str4='!';
str = strcat(str1,str2,str3,str4);
%output: str=I love you!
%s = strcat(s1,...,sN) 水平串联 s1,...,sN。每个输入参数都可以是字符数组、字符向量元胞数组或字符串数组
%for example
% 1、字符数组
%该种方式是组合使用了字符串数组和strcat两种方式来拼接字符串。首先使用字符数拼接数组内的字符串,再将字符数据拼接后的字符串最为参数传递给strcat进行第二次拼接。
str = strcat(['hello' ' world,'],[' hello' ' Matlab!']);
% output: str = hello world, hello Matlab!
% 2、字符串数组
str = strcat(["